PHP
Composer
phpcs
PHP_CodeSniffer

phpcsをcomposerで導入しつつ、独自rulesetを使う

phpcsをcomposerで導入する

$ composer global require squizlabs/php_codesniffer

実行したユーザの ~/.composer/bin/phpcs にパスが通るようにしておく

.basrhcなど
export PATH=$HOME/.composer/vendor/bin:$PATH
$ which phpcs
~/.composer/vendor/bin/phpcs

独自rulesetを使う

  • 独自rulesetを置くパスを指定
$ phpcs --config-set installed_paths ~/.phpcs
  • ruleset.xmlを置く
$ mkdir -p ~/.phpcs/MyStandard
$ cp ruleset.xml ~/.phpcs/MyStandard
$ phpcs -i
The installed coding standards are Zend, Squiz, PSR2, MySource, PEAR, PSR1 and MyStandard
  • デフォルトのrulesetを指定
$ phpcs --config-set default_standard MyStandard

参考

https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-installed-standard-paths
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-default-coding-standard