Code Sniffer (
phpcs) is a comamnd line tool which validates php source code files against specified coding stanadard.
brew install php-code-sniffer
git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git /usr/local/etc/php-code-sniffer/Standards
phpcs --config-set default_standard WordPress
TODO: Instructions for Ubuntu
You can use https://atom.io/packages/linter-phpcs . There are few more options.
apm install linter-phpcs
"linter-phpcs": phpcsExecutablePath: "/usr/local/bin/phpcs" standard: "WordPress" enableWarning: 1
In above confif
/usr/local/bin/phpcs is path to
phpcs binary. Please verify if path is correct by running
which phpcs command on your machine.
phpcs -i- show coding standards installed
phpcs <filename>- run phpcs on specified file
phpcs .- run phpcs recursively in current dir
phpcs has a companion script
phpcbf. It automatically fixes codes based on
All you need to do is - just run
phpcbf instead of
Please note that all
phpcs recommendation can not be fixed by
phpcbf so once you run
phpcbf, check again with