Last active
February 3, 2020 09:42
-
-
Save w-jerome/e1a46b8ca43e2b384c3c54a67d10eec2 to your computer and use it in GitHub Desktop.
PHP Code Sniffer - Install "PHP Code Sniffer" and "WordPress Coding Standards" ("phpcs" and "wpcs")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1: Install PHP Code Sniffer (global) | |
composer global require squizlabs/php_codesniffer | |
# path: "/Users/MyUserName/.composer/vendor/squizlabs/php_codesniffer/bin" | |
# Step 2: Install WordPress Coding Standards (global) | |
# stock the git in user folder | |
cd ~ | |
mkdir ~/terminal-tools | |
cd ~/terminal-tools | |
# clone the git | |
git clone https://github.com/WordPress/WordPress-Coding-Standards.git wpcs | |
# Step 3: Add WordPress Coding Standards config to PHP Code Sniffer | |
~/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs --config-set installed_paths ./wpcs | |
# Step 4: Add PHP Code Sniffer config to your project | |
cd ~/Sites/my-project/ | |
~/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs --config-set default_standard WordPress | |
# Step bonus: Add "phpcs" in your terminal (zsh) | |
vim ~/.zshrc | |
# add line | |
alias phpcs="~/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment