Moodle HQ’s senior developer and integrator Dan Poltawski gave this talk at MoodleMoot US, just weeks ago. It gives both novice and advanced “moodlevelopers” Tools and Tips to invigorate our daily practice.
config.php hidden settings
There are advanced debugging settings in Moodle beyond the administrator settings. Look in the config.php file for section 7, “Settings for development servers“. Focus on debug-related configuration variables, such as
Another set of variables relate to performance of your Moodle:
When you include this variables in
config.php, the footer in Moodle pages will include performance info such as the time it took to load the page and the amount of memory used.
Profiling with XHProf
To precisely identify performance bottlenecks in your Moodle, Dan seems to recommend XHProf over the other available profiling tools. It is easy to set up and it has little impact on memory, which can make it preferable even if it is not as detailed as XDebug. It also has the ability to track live servers in addition to development environments.
Set up XHProf and get started on Moodle Performance Testing. It is trickier to do in a Windows than a Linux server as it is often the case.
More of XHProf:
Unit Testing with Framework: PHPUnit
For writing unit tests for Moodle, PHPUnit is the way to go. Allowing you to separate production code from testing benchmarks, PHPUnit is crazy easy to set up and start using. You can write your first PHPUnit test in a matter of minutes. It’s all about knowing what you expect your code to do and setting up the
assertEquals() function accordingly.
PHPUnit allows for authoring, filtering and coverage analysis. Another interesting feature is
@dataProvider to write a large number of data input test, over which PHPUnit will automatically iterate.
Set up PHPUnit once, have modular, authored testing units for a (production) lifetime.
Behavior Driven Development with Behat
Behavior-Driven Development has been for some time, but if it has gained traction lately it only has Behat to thank. The idea is attractive, in particular for those on the business end: using English-like syntax in sentences, a program builds a scenario comprised of assumptions, behaviors and expected outcomes. Behat is a test scripting tool for PHP that allows you to do just that.
Without a graphical interface, some ‘headless’ outcome tools can help the task of comparing expected to realized outcomes. Dan mentions PhantomJS (for all systems), Xvfb (Linux) and Fast User Switching (Mac).
It is not a bad idea to spend a little more on Behat for some direction and perspective, before jumping into coding.
Automate everything with Grunt
watch plugin makes Grunt alert for changes to incorporate into the next iteration of tasks, or automatically if you wish so.
I can’t help it. When I read it, the word ‘lint’ takes me back to a spring cleaning scenario, removing dust and little fibers from wooden furniture.
ESLint replaces JSHint as default in Moodle 3.2
Be sure to add Lint add-ons to your IDE. Dan shows options for Atom, vim, PHPStorm and Sublime.
More tools, briefly mentioned by Dan:
moodle-plugin-cifor plugin unit testing
- Moodle Developer Kit, a curated collection of tools
- ChromeVox and Accessibility Developer Tools for Accessibility Testing
who-broke-itto repare code from culprit Git commits
Spark the conversation below!