# Download using curl
curl --url https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar --output /usr/local/bin/phpcs
curl --url https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar --output /usr/local/bin/phpcbf
Code language: JavaScript (javascript)
# Give the execution permissions
sudo chmod +x /usr/local/bin/phpcs
sudo chmod +x /usr/local/bin/phpcbf
# Install WordPress Coding Standards
composer global require "wp-coding-standards/wpcs"
Code language: PHP (php)
# Apply the new coding standards
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
Code language: JavaScript (javascript)
# Update the default standard
phpcs --config-set default_standard WordPress
Code language: JavaScript (javascript)
# Install the VS Code Extension
PHP Sniffer & Beautifier: https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpsab
# Add these settings to the settings.json file of VS Code
// PHPCS & PHPCBF
"phpsab.fixerEnable": true,
"phpsab.snifferEnable": true,
"phpsab.executablePathCS": "/usr/local/bin/phpcs",
"phpsab.executablePathCBF": "/usr/local/bin/phpcbf",
"phpsab.standard": "WordPress",
"phpsab.snifferMode": "onType",
"phpsab.snifferTypeDelay": 250,
Code language: JSON / JSON with Comments (json)
Leave a Reply