Install PHPCS
To install PHPCS, use the following command:
composer global require "squizlabs/php_codesniffer=*"
This installs the PHPCS package globally on your system.
Install WPCS
Once PHPCS is installed, you can install the WordPress Coding Standards (WPCS) with:
composer global require "wp-coding-standards/wpcs=*"
This adds the WPCS rules to your PHPCS setup.
Configure PHPCS to Use WPCS
Now that PHPCS and WPCS are installed, you’ll need to tell PHPCS to use the WordPress coding standards. Run this command:
phpcs --config-set installed_paths /Users/user/.composer/vendor/wp-coding-standards/wpcs
This sets the correct path for the WPCS standards.
Verify the Installation
To check if everything is working, run this command:
phpcs -i
This will show you the available coding standards, including WordPress.
Leave a Reply