Skip to content
Ruleset for PHPCodesniffer to use with SilverStripe
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

SilverStripe Codesniffer ruleset

This is a proposed ruleset for SilverStripe projects.

It tries to follow the official guidelines from

This relies on the PHPCodesniffer being installed

General Installation

  1. First install PHPCodesniffer, check for it's existens via:

    phpcs --version

If it's not installed, the easiest way to install is via PEAR. Instructions here:

  1. Checkout this project somewhere on your hardrive

    git clone git:// SilverStripe

NOTE: It is critical that the base directory for this standard is named "SilverStripe", otherwise the PHPCodesniffer autoloader will fail.

Running the codesniffer

phpcs --standard=silverstripe-codesniffer/ --tab-width=4  path/to/your/code

NOTE: Beware, running this on a whole silverstripe installation takes to long to be worth it. Use it on your mysite module or target specific directories.

Install for Mac OS X

After you have installed PHP Codesniffer via pear, you should have a pear folder in your home directory, example:


git clone this repository into the PHP Codesniffer standards directory:

 git clone git:// /Users/slindqvist/pear/share/pear/PHP/CodeSniffer/Standards/SilverStripe

If you are primary developing SilverStripe projects, you can set a couple of PHP CS settings as default:

 phpcs --config-set default_standard SilverStripe
 phpcs --config-set report_width 120
 phpcs --config-set encoding utf-8

With this setup you only need run phpcs like this:

 phpcs cms


Feel free to help me clear up the ruleset and remove / add missing rules and sniffs. Best way is to see what can be used is to read the sourcecode of the PHPCodesniffer.

You can’t perform that action at this time.