$ composer require --dev squizlabs/php_codesniffer
$ phpcs /path/to/myfile.php
$ phpcs /path/to/project/
$ phpcs --report=summary /path/to/code
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE ERRORS WARNINGS
--------------------------------------------------------------------------------
/path/to/code/myfile.inc 5 0
/path/to/code/yourfile.inc 1 1
/path/to/code/ourfile.inc 0 2
--------------------------------------------------------------------------------
A TOTAL OF 6 ERROR(S) AND 3 WARNING(S) WERE FOUND IN 3 FILE(S)
--------------------------------------------------------------------------------
$ phpcs -i
The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend
$ ./vendor/bin/phpcs --report=summary ./source/
$ phpcs --standard=PEAR --sniffs=Generic.PHP.LowerCaseConstant,PEAR.WhiteSpace.ScopeIndent /path/to/code
$ phpcs --standard=PEAR --exclude=Generic.PHP.LowerCaseConstant,PEAR.WhiteSpace.ScopeIndent /path/to/code
$ phpcs --severity=3 /path/to/code
$ phpcs --tab-width=4 /path/to/code
$ phpcs -d memory_limit=32M /path/to/code
Default config file is called 'phpcs.xml'
Example 'phpcs.xml' from "Make PHP CS Work for You" by @jrf_nl
You can view proposed changes before you do it
$ phpcs --report=diff /path/to/code