André Amorim

Crafting Web Experiences

//

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

# Download using curl

curl --url https:
curl --url https:

# 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"

# Apply the new coding standards

phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs

# Update the default standard

phpcs --config-set default_standard WordPress

# 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

  
    "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,

Published date:

Modified date: