Skip to content

Latest commit

 

History

History
72 lines (31 loc) · 1.96 KB

README.md

File metadata and controls

72 lines (31 loc) · 1.96 KB

moodle-styleguide

Moodle coding style

Moodle has some very specific styling that should be followed, check out the coding style guide at:

www.moodledev.io

Setting up your linter

The linter recommended for moodle development is PHP Sniffer. PHP Sniffer is a tool used to analyse PHP code using a set of rules. In many cases these rules can be used to automatically fix the errors they identify.

The following are the steps to set up PHP Codesniffer:

  1. Start by installing composer, the steps are provided in the link below:

    www.digitalocean.com

  2. Install composer dependencies:

    composer global require "squizlabs/php_codesniffer=*"
    
    composer global require moodlehq/moodle-cs
  3. Add composer's path to your bashrc:

    export PATH="$PATH:$HOME/.config/composer/vendor/bin"
  4. Install PHP Sniffer in VS Code:

    • Press Ctrl+P on Linux/Windows or Cmd+P on Mac to open the Quick Open dialog.

    • Type ext install wongjn.php-sniffer to find the extension.

    • Press Enter or click the cloud icon to install it.

    • Restart Visual Studio Code when prompted.

  5. Test that PHP Sniffer is working:

    • Open any php file.

    • Add a variable in camel case.

    • Save changes and check that an error pops up for the incorrect case used.

Upgrading Plugin

To upgrade your plugin, certain files must be updated for moodle to detect that there is a new version of your plugin, please see the following links below:

Moodle Upgrade Plugin Guide

Moodle Upgrade API Guide