-
-
Save andrewlimaza/fe68efd141e2e9e8d8e46407d90b90b2 to your computer and use it in GitHub Desktop.
Install PHPCS with WordPress Coding Standard with Sublime Text 3
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
mkdir ~/code | |
cd ~/code | |
# install phpcs and phpmd | |
git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs | |
git clone git://github.com/phpmd/phpmd.git | |
# install composer into your bin folder (Skip if already have composer) | |
curl -s http://getcomposer.org/installer | php | |
# install dependencies | |
cd phpcs | |
composer install | |
cd .. | |
cd phpmd | |
composer install | |
cd .. | |
# add composer, phpcs and phpmd to your path | |
sudo ln -s ~/code/phpcs/scripts/phpcs /usr/local/bin/phpcs | |
sudo ln -s ~/code/phpmd/src/bin/phpmd /usr/local/bin/phpmd | |
sudo ln -s ~/code/composer.phar /usr/local/bin/composer |
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
#optional part to install wordpress coding standards | |
cd ~/code | |
git clone https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs | |
# tell phpcs about the wordpress coding standards (ensure you are still in ~/code dir) | |
cd ~/phpcs | |
scripts/phpcs --config-set installed_paths ../wpcs | |
# we probably want to ignore the space indenting on the files | |
nano ~/code/ruleset.xml | |
# See ruleset.xml, paste into new xml file and press ctrl + x to save, follow prompts at bottom of the terminal. (Y to save changes and hit enter). |
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
<?xml version="1.0"?> | |
<ruleset name="Custom"> | |
<description>Wordpress, but without linelength check.</description> | |
<rule ref="WordPress"> | |
<exclude name="Generic.Files.LineLength"/> | |
<exclude name="Generic.WhiteSpace.ScopeIndent"/> | |
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent"/> | |
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/> | |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis"/> | |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis"/> | |
<exclude name="WordPress.Arrays.ArrayDeclaration"/> | |
<exclude name="WordPress.PHP.YodaConditions"/> | |
<exclude name="WordPress.XSS.EscapeOutput"/> | |
<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions"/> | |
<exclude name="WordPress.WhiteSpace.CastStructureSpacing"/> | |
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/> | |
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket"/> | |
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket"/> | |
</rule> | |
</ruleset> |
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
1. cmd+shift+p | |
2. Type phpcs and install it | |
3. Preferences > Package Settings > PHP Code Sniffer > Settings - User |
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
{ | |
"phpcs_executable_path" : "/usr/local/bin/phpcs", | |
"phpmd_executable_path" : "/usr/local/bin/phpmd", | |
"phpcs_additional_args": { | |
"--standard": "~/bin/ruleset.xml", | |
"-n": "" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment