You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
moodle-extra - extended ruleset which includes recommended best practices
extends the main moodle ruleset
Currently this only includes the configuration for PHP Coding style, but this may be extended to include custom rules for JavaScript, and any other supported languages or syntaxes.
Installation
Using Composer (recommended)
You can install these coding style rules using Composer to make them available globally across your system.
This will install the correct version of phpcs, with the Moodle rules, and their dependencies.
composer global config minimum-stability dev
composer global require moodlehq/moodle-cs
Configuration
Typically configuration is not required. Recent versions of Moodle (3.11 onwards) include a configuration file for the PHP CodeSniffer, which will set the standard when run within a Moodle directory.
Additional configuration can be generated automatically to have PHP CodeSniffer ignore any third-party library code. This can be generated by running:
npx grunt ignorefiles
Using the moodle-extra coding style
The recommended way of configuring PHP CodeSniffer to use the moodle-extra coding style is to provide an additional configuration file.
For Moodle 3.11 onwards you can create a file named .phpcs.xml with the following contents: