-
Notifications
You must be signed in to change notification settings - Fork 0
Phpcs and Phpcbf setup
Mosne edited this page Jul 14, 2020
·
1 revision
Download and install:
$ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
$ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
$ chmod +x phpcs.phar
$ chmod +x phpcbf.phar
$ sudo mv phpcs.phar /usr/local/bin/phpcs
$ sudo mv phpcbf.phar /usr/local/bin/phpcbf
Download WordPress Coding standard:
$ git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
Set the ABSOLUTE path to thw wpcs folder and the default rules.
$ sudo phpcs --config-set installed_paths /User/[your_user_name]/wpcs
$ sudo phpcs --config-set default_standard WordPress-Extra
Verify your configuration:
$ phpcs -i
$ phpcbf -i
Install the following plugins:
Edit your configuration file:
"phpcs.standard": "WordPress-Extra",
"phpcbf.enable": true,
"phpcbf.executablePath": "phpcbf",
"phpcbf.documentFormattingProvider": true,
"phpcbf.onsave": true,
"phpcbf.standard": "WordPress-Extra",