-
Notifications
You must be signed in to change notification settings - Fork 0
Configuring PHP Codesniffer
PHP Codesniffer can be used to automatically check your code for style issues. This can be done through a Git pre-commit hook. The hook will prevent you from committing code that does not conform to the Joomla Platform coding standards.
To add this hook, first install PHP Codesniffer. Once PHP Codesniffer is installed, you will need to know where the phpcs
binary is located. This can typically be found by entering which phpcs
on the command line.
Finally, you will need to add the hook itself. This project has a PHP Codesniffer Git hook ready to configure. Once you've copied the config
and pre-commit
files into the .git/hooks
folder, make sure that pre-commit
is executable. Then edit the config
file, supplying values for these variables:
-
PHPCS_BIN
- use the full path to yourphpcs
binary -
PHPCS_CODING_STANDARD
- set this tobuild/phpcs/Joomla
Now, whenever you commit code, it will be checked against the Joomla Platform coding standards. If there are any issues in files you have changed, it will stop the commit and display a report.