Crowdcube PHP_Codesniffer Standard

0.3.8 2016-04-07 08:16 UTC


Circle CI

This is our work-in-progress PHP_Codesniffer standard for validating the PHP code that we write.

It currently does not check/enforce all, but serves as a good first check to the Crowdcube coding standard. The remaining checks will be picked up in code review.


Add the following to your composer.json require and update:

"crowdcube/codesniffer-standard": "0.3.*"


When running ./vendor/bin/phpcs from your project, set the standard as follows:


Integration with PHPStorm

You can configure PHP Storm to automatically check using this standard.

Install CodeSniffer

Use the following command to install:

pear install PHP_CodeSniffer-2.5.0

Pointing PHPStorm to CodeSniffer

  1. Visit the Code Sniffer configuration panel: Preferences > Languages & Frameworks > PHP > Code Sniffer
  2. In the drop-down, select 'Local' configuration, then click the [ ... ] button
  3. The new window will house another [ ... ] button which'll allow you to point the IDE to your bin file for phpcs

Set up the Inspector

  1. Visit the Inspector configuration panel: Preferences > Editor > Inspections
  2. Find 'PHP CodeSniffer validation' beneath the PHP tab
  3. Customise the severity and error reporting to your liking
  4. In the 'Code Standard' drop down, change it to 'Custom'
  5. Click the [ ... ] button, and in the new window, add the path to this repository's 'Crowdcube' directory

Now any php files you open will be checked by the sniffer and you will be alerted to your chosen level of severity.