Difference between revisions of "Setup PHP CodeSniffer"
(→Setup Wordpress Coding Standards (modified by Glma)) |
(→Visual Studio Code) |
||
Line 25: | Line 25: | ||
{ | { | ||
... | ... | ||
− | "phpcs.executablePath": "/ | + | "phpcs.executablePath": "/home/{user name}/bin/phpcs", |
"phpcs.standard": "WordPress-Extra", | "phpcs.standard": "WordPress-Extra", | ||
... | ... |
Revision as of 09:22, 19 December 2019
Contents
Setup PHP CodeSniffer
Instructions for linux
1. Setup a bin directory in your home folder. 2. Add your bin directory to your PATH variable. 3. Download phpcs and phpcbf files into your bin directory. 4. Rename them to phpcs and phpcbf. 5. Test that they work and files are executable by your user.
Setup Wordpress Coding Standards (modified by Glma)
1. Clone our forked copy of Wordpress Coding Standards to a directory named wpcs somewhere in your home directory.
git clone ssh://git@bitbucket.gaslightmedia.com:7999/doc/wordpress-coding-standards.git wpcs
2. Add its path to the PHP_CodeSniffer configuration
phpcs --config-set installed_paths {your path to wpcs}/wpcs
3. Test phpcs finds it using 'phpcs -i' 4. Set WordPress as the default standard using
phpcs --config-set default_standard WordPress
Visual Studio Code
Install and enable the phpcs extension by Ioannis Kappas (ikappas.phpcs).
In your user settings – CMD+, on Mac or Preferences -> Settings – set these two variables:
{ ... "phpcs.executablePath": "/home/{user name}/bin/phpcs", "phpcs.standard": "WordPress-Extra", ... }
Again, the executablePath should be the result of which phpcs.
Restart VSCode, and you should have code standards enabled.