The coding standard of the Doctrine project.
PHP
Switch branches/tags
Nothing to show
Latest commit fe7696b Jul 16, 2015 @Ocramius Ocramius Merge pull request #4 from phansys/composer_improvements
[Install] Some updates
Permalink
Failed to load latest commit information.
Docs
Sniffs/Strings
Tests/Strings
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml.dist
ruleset.xml
tests_bootstrap.php

README.md

Doctrine PHP_CodeSniffer Coding Standard

Build Status Coverage Status

The PHP_CodeSniffer Coding Standard to check against the Doctrine Coding Standard.

Installation

You have three possibilities to use the Doctrine Coding Standard with PHP_CodeSniffer in a particular project.

1. Standalone installation

You can install the Doctrine Coding Standard as a plugin into your global system PHP_CodeSniffer installation:

$ cd /path/to/phpcs/CodeSniffer/Standards
$ php composer create-project doctrine/coding-standard Doctrine ~0.1@dev

Then you can use it like (assuming that you have the phpcs binary in your search path):

$ phpcs --standard=Doctrine /path/to/some/file/to/sniff.php

Or even set it as default standard (assuming that you have the phpcs binary in your search path):

$ phpcs --config-set default_standard Doctrine

And just sniff a particular file with (assuming that you have the phpcs binary in your search path):

$ phpcs /path/to/some/file/to/sniff.php

2. Global installation

You also can install the Doctrine Coding Standard globally:

$ php composer global require doctrine/coding-standard:~0.1@dev

Then you can use it like:

$ phpcs --standard=~/.composer/vendor/doctrine/coding-standard/Doctrine /path/to/some/file/to/sniff.php

Or even set it as default standard:

$ phpcs --config-set default_standard ~/.composer/vendor/doctrine/coding-standard/Doctrine

And just sniff a particular file with:

$ phpcs /path/to/some/file/to/sniff.php

3. Custom installation

You can install the Doctrine Coding Standard anywhere you want:

$ php composer create-project doctrine/coding-standard /path/to/coding-standard/Doctrine ~0.1@dev

Then you can use it like:

$ ./vendor/bin/phpcs --standard=. /path/to/some/file/to/sniff.php

4. As a composer dependency of your project

You can install the Doctrine Coding Standard as a composer dependency to your particular project. Just add the following block to your project's composer.json file:

$ php composer require doctrine/coding-standard:~0.1@dev

Then you can use it like:

$ ./vendor/bin/phpcs --standard=vendor/doctrine/coding-standard/Doctrine /path/to/some/file/to/sniff.php

Testing

If you are contributing to the Doctrine Coding Standard and want to test your contribution, you have to make sure all dependencies are correctly installed:

$ php composer install --prefer-source

The option --prefer-source is particularly necessary to ensure the test suite from PHP_CodeSniffer is installed. Otherwise the test suite for the Doctrine Coding Standard won't work!

Run the test suite with:

$ ./vendor/bin/phpunit