Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Forked from vishalbasnet23/Sublime-stuffs.txt
Created April 1, 2017 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pbrocks/e06d1176296a814a00785a2ae9c27fd1 to your computer and use it in GitHub Desktop.
Save pbrocks/e06d1176296a814a00785a2ae9c27fd1 to your computer and use it in GitHub Desktop.
Install PHPCS with WordPress Coding Standard with Sublime Text 3
mkdir ~/bin
cd ~/bin
# 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
curl -s http://getcomposer.org/installer | php
# add composer, phpcs and phpmd to your path
sudo ln -s ~/bin/phpcs/scripts/phpcs /usr/local/bin/phpcs
sudo ln -s ~/bin/phpmd/src/bin/phpmd /usr/local/bin/phpmd
sudo ln -s ~/bin/composer.phar /usr/local/bin/composer
# configure phpmd
cd ~/bin/phpmd
composer install
#optional part to install wordpress coding standards
git clone https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
# tell phpcs about the wordpress coding standards
cd ~/bin/phpcs
scripts/phpcs --config-set installed_paths ../wpcs
# we probably want to ignore the space indenting on the files
vim ~/bin/ruleset.xml
<?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>
1. cmd+shift+p
2. Type phpcs and install it
3. Preferences > Package Settings > Php Code Sniffer > User settings
{
"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