If you’re developing for WordPress then, in my opinion, use of PHPCS to help validate your code is critical.
However, anyone can develop without necessarily being a whizz with the command line (and I include myself in that bracket). So, having just gone through a PHPCS install with a freshly-baked MacBook, I thought I’d share the process. If only for me the next time I do it.
The instructions that I use, by the way, install not just the WordPress sniffs but those from WordPress VIP as well – you can happily ignore the latter ones, but they’re there if you want to use them.
The thing about installing this all, though, is that there are dependencies. And those have dependencies. So it’s a bit of a slog getting to the actual “and now you install PHPCS” part.
- Install Homebrew (required to install PHP)
- Install PHP (required to install Composer)
- Install Composer (required to install PHPCS)
Now we finally get to…
- Install PHPCS
The “Troubleshooting” section of those instructions give you an example of correcting the path using Bash. If you’re using ZSH, then you’d edit the file
~/.zshrc and add the line…
Updating PHPCS and Sniffs
To update all-the-things, simply run this…
composer g update automattic/vipwpcs