GLOBAL: PHPCS, PHPCBF, and WPCS Coding Standards with VS Code

# Download using curl

curl --url --output /usr/local/bin/phpcs curl --url --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:

# 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

Your email address will not be published. Required fields are marked *