General plugins (Local) ::: local_codechecker
Maintained by One poor developer...Eloy Lafuente (stronk7), Tim at Lone Pine Koala SanctuaryTim Hunt, Picture of Víctor Déniz FalcónVíctor Déniz Falcón, Picture of Sara Arjona TéllezSara Arjona Téllez
A tool for developers that helps them follow Moodle's coding style.

Code-checker 3.0.0 - Welcome phpcs 3

Moodle 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10
Released: Monday, November 30, 2020, 4:37 PM

Moodle Code Checker

Build Status

Changes in version 3.0.0 (20201127) - Welcome phpcs 3

  • Upgrade to PHP_CodeSniffer 3.5.8 (stronk7):
    • PHP_CodeSniffer move to phpcs directory (see readme_moodle.txt for complete instructions).
    • Move Moodle sniffs to PHP_CodeSniffer 3.
    • Create own runner/report.
    • Move as much as possible from locallib.php to classes.
    • Add PHPUnit 8 compatibility, keeping PHPUnit 6 working.
    • Min Moodle version required increases from 3.2 to 3.4.
  • PR#90: Adapt custom PHP_CodeSniffer runner (classes/runner.php) to use PHP_CodeSniffer 3 API (Sara Arjona).
  • PR#95: Unlock session before processing files (Víctor Déniz).


This Moodle plugin uses the PHP CodeSniffer tool to check that code follows the Moodle coding style. It implements and reuses a set of 'sniffs' that check many aspects of the code, including the awesome PHPCompatibility ones.

It was created by developers at the Open University, including Sam Marshall, Tim Hunt and Jenny Gray. It is now maintained by Moodle HQ.

Available releases can be downloaded and installed from .

To install it using git, type this command in the root of your Moodle install:

git clone git:// local/codechecker

Then add /local/codechecker to your git ignore.

Additionally, remember to only use the version of PHPCS located in phpcs/bin/phpcs rather than installing PHPCS directly. Add the location of the PHPCS executable to your system path, tell PHPCS about the Moodle coding standard with phpcs --config-set installed_paths /path/to/moodle-local_codechecker and set the default coding standard to Moodle with phpcs --config-set default_standard moodle. You can now test a file (or folder) with: phpcs /path/to/file.php.

Alternatively, download the zip from , unzip it into the local folder, and then rename the new folder to "codechecker".

After you have installed this local plugin, you should see a new option in the settings block:

> Site administration -> Development -> Code checker

We hope you find this tool useful. Please feel free to enhance it. Report any idea or bug in the Tracker, thanks!

IDE Integration


  1. Outdated!: If if you use Eclipse for development, you might want to install the PHP CodeSniffer plugin (
  2. Create a new "CodeSniffer standard" in the preferences page.
  3. Point it at the moodle directory inside the codechecker folder.
  4. Thank Michael Aherne from University of Strathclyde who worked this out!


  1. Install the phpcs cli tool
  2. Open PhpStorm preferences
  3. Go to PHP > CodeSniffer and supply the path to the phpcs executable
  4. Go to Inspections > PHP > PHP Code Sniffer Validation
  5. In the 'coding standard' dropdown select 'custom' and press the [...] button next to the path to the coding standard. Point is at the moodle directory inside the this plugin directory.

Sublime Text

Find documentation here.

After step 3 in the Sublime PHP CS section:

  1. Go in your Sublime Text to Preferences -> Package Control -> Package Control: Install Package
  2. Write 'phpcs' in the search field, if you see Phpcs and SublimeLinter-phpcs, click on them to install them.
  3. If not, check if they are already installed Preferences -> Package Control -> Package Control: Remove Package.
  4. To set your codecheck to moodle standards go to Preferences -> Package Settings -> PHP Code Sniffer -> Settings-User and write:

    { "phpcs_additional_args": {
            "--standard": "moodle",
            "-n": "
  5. If you don’t have the auto-save plugin turned on, YOU’RE DONE!

  6. If you have the auto-save plugin turned on, because the codecheck gets triggered on save, the quick panel will keep popping making it impossible to type. To stop quick panel from showing go to Settings-User file and add:

    "phpcs_show_quick_panel": false,

    The line with the error will still get marked and if you’ll click on it you’ll see the error text in the status bar.

Version information

Version build number
Version release name
3.0.0 - Welcome phpcs 3
Stable version
MD5 Sum
Supported software
Moodle 3.4, Moodle 3.5, Moodle 3.6, Moodle 3.7, Moodle 3.8, Moodle 3.9, Moodle 3.10

Version control information

Version control system (VCS)
VCS repository URL
VCS branch
VCS tag

Default installation instructions for plugins of the type General plugins (Local)

  1. Make sure you have all the required versions.
  2. Download and unpack the module.
  3. Place the folder in the "local" subdirectory.
  4. Visit to finish the installation.