7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-09-26

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

7
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?