###How to use this with Sublime Text 3
on Ubuntu
or OSX
?
To use this you need docker installed.
-
Install Docker container
docker pull saidatom/phpcs
-
Install this sublime text plugin https://packagecontrol.io/packages/Phpcs https://packagecontrol.io/packages/PHP%20Codebeautifier
-
clone this repo
git clone https://github.com/saidatom/phpcs.git
cd phpcs
if you are using Ubuntu, comment line 8 and uncomment line 10 in all files.
sudo cp phpcs.sh /usr/local/bin/phpcs
sudo cp phpcbf.sh /usr/local/bin/phpcbf
sudo cp phpmd.sh /usr/local/bin/phpmd
sudo cp php-cs-fixer.sh /usr/local/bin/php-cs-fixer
- Open
Preferences > Package Settings > PHP Code Sniffer > Settings - User
- Copy these settings
{
"phpcs_executable_path": "/usr/local/bin/phpcs",
"phpcbf_executable_path": "/usr/local/bin/phpcbf",
"phpmd_executable_path": "/usr/local/bin/phpmd",
"php_cs_fixer_executable_path": "/usr/local/bin/php-cs-fixer",
"phpcbf_additional_args": {
"--standard": "Drupal,DrupalPractice,PSR2",
"-n": "",
"--no-patch":""
}
}
- On every save it will show errors in code
- Fix errors automatically
Ctrl + Shift + P
and select optionPHP Code Beautifier