2

I really like PHPCS, but having to type in --ignore=vendor each time is a pain. I've had a good look around but can't find anything on the subject.

I've added the following to my .bash_profile, but I was hoping there might be a better idea.

alias phpcs="command phpcs --ignore=vendor"
1
  • Without duplicating the ruleset or using a build tool, it looks like the bash alias option might be the easiest. Thanks for the suggestions. Mar 10, 2015 at 16:50

3 Answers 3

2

Easiest answer is just to use a bash alias. alias phpcs="command phpcs --ignore=vendor"

1

Firstly, I think your choice is great if what you want is to save yourself time. I'll give you a different suggestion.

You can use ant, and make it run phpcs with the options that you want, so you could run just "ant" from the command line.

I also suggest you have a look at phpmd, it's awesome to enforce code quality.

1
  • Not a bad option, but looking to keep away from ant. I'll probably be moving to grunt or gulp in the near future, so something similar there might be an idea. Mar 10, 2015 at 16:44
0

If you create your own ruleset.xml file, you can set default exclude paths, define your own coding standard rules, and configure all parts of PHP_CodeSniffer. The syntax is documented here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml

The bit you're looking for is the exclude-pattern tag.

It's a good idea to commit the ruleset.xml file into the project's repository directly so all developers can use it. Then each developer can run phpcs --standard=/path/to/ruleset.xml /path/to/code or, from the project's root directory phpcs --standard=ruleset.xml . to use relative paths.

1
  • Combine this with the phpcs --config-set default_standard command and it might work. But at the moment, the bash alias is still my easiest option. Mar 10, 2015 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.