🔍 PHP CodeSniffer, PHP Coding Standard Fixer, Linter, and Mess Detector Support for Sublime Text
Python
807
182 commits
updated Mar 18, 2026
This is a plugin for Sublime Text which provides checkstyle reports using the following tools (all optional):
phpcs)php -l)phpmd)You can also configure the plugin to fix the issues using either
Requirements for this plugin, should you want all the options to work:
This plugin has been tested on:
It may work with other versions, but we cannot confirm that.
Use Sublime Text’s Package Control (Tools -> Command Palette -> Package Control: Install Package -> Phpcs) to install this plugin. This is the recommended installation path.
Or
Simply checkout the git repo into “~/Library/Application Support/Sublime Text/Packages/ or the equivalent folder on Windows or Linux.
cd ~/Library/Application\ Support/Sublime\ Text/Packages/
git clone git://github.com/benmatselby/sublime-phpcs.git Phpcs
In both cases, you may need to then configure the following with the actual path to the application:
They are optional for the plugin. The path needs to include the application such as /usr/local/bin/phpcs.
In order to get the path of the application (On a Mac/Linux based environment), you can use:
which phpcs
which phpmd
which php-cs-fixer
which phpcbf
Once you have right clicked on a file and selected “PHP CodeSniffer” > “Sniff this file…” you will get the output as shown below (depending on the settings you have defined):
You can also define the configuration for the following settings, be it for a project, user settings or the default settings:
show_debug – Do you want the debug information to be sent to the console?extensions_to_execute – Which filetypes do you want the plugin to execute for?extensions_to_blacklist – Override the extensions_to_execute in case you have a sub extension such as twig.php etc.phpcs_execute_on_save – Do you want the code sniffer plugin to run on file save for php files?phpcs_show_errors_on_save – Do you want the errors to be displayed in quick_panel on save?phpcs_show_gutter_marks – Do you want the errors to be displayed in the gutter?phpcs_outline_for_errors – Do you want the errors to be highlighted in the editor?phpcs_show_errors_in_status – Do you want the errors to be displayed in status bar when clicking on the line with error?phpcs_show_quick_panel – Do you want the errors to be displayed in the quick panel?phpcs_php_prefix_path – Needed on windows for phar based applications. Also if you cannot make phar executable. Avoid if possiblephpcs_commands_to_php_prefix – List of commands you want the php path to prefix. This would be useful, if you have some commands as a phar that cannot be run without the php prefix, and others using native command.phpcs_icon_scope_color - What colour to stylise the icon. This needs knowledge of theming of Sublime Test, as it uses scope colours from the theme to “tint” the dot icon. See herephpcs_sniffer_run – Do you want the PHPCS checker to run?phpcs_command_on_save – Do you want the command to execute on save?phpcs_executable_path – The path to the phpcs executable. If empty string, use PATH to find itphpcs_additional_args – This is the extra information you want to pass to the phpcs command. For example which “standard” you want to run, and if you want to show warnings or notphp_cs_fixer_on_save – Do you want to run the fixer on file save?php_cs_fixer_show_quick_panel – Do you want the quick panel to display on execution?php_cs_fixer_executable_path – The path to the php-cs-fixer application.php_cs_fixer_additional_args – This is the extra information you want to pass to the php-cs-fixer command. For example which “fixers” you want to run
"--cache-file": "${project_path}/php-cs-fixer.cache", or equivalent for your project.phpcbf_on_save – Do you want to run the fixer on file save?phpcbf_show_quick_panel – Do you want the quick panel to display on execution?phpcbf_executable_path – The path to the phpcbf application.phpcbf_additional_args – This is the extra information you want to pass to the phpcbf command. For example which “standard” to use in order to fix the issuesphpcs_linter_run – Do you want the PHP linter to run?phpcs_linter_command_on_save – Do you want the command to execute on save?phpcs_php_path – The path to the PHP executable. If empty string, use PATH to find itphpcs_linter_regex – The regex for the PHP linter outputphpmd_run – Do you want the PHPMD to run? Off by defaultphpmd_command_on_save – Do you want the command to execute on save?phpmd_executable_path – The path to the phpmd executable. If empty string, use PATH to find itphpmd_additional_args – This is the extra information you want to pass to the phpmd command. For example which “rulesets” you want to runYour .project file should look something like this:
{
"folders": [{}],
"settings": {
"phpcs": {
"phpcs_additional_args": {
"--standard": "/path/to/.composer/vendor/drupal/coder/coder_sniffer/Drupal"
}
}
}
}
Of course, this is an example of how to apply Drupal standards for the Code Sniffer. This could be anything. Whatever you can have on this package settings it can be overwritten under the settings -> phpcs.
If you use this plugin across multiple operating systems (e.g. syncing settings between Windows and Linux), you can specify platform-specific values for any path setting by using a dictionary instead of a string. The supported platform keys are "windows", "linux", and "osx". You can also specify a "default" key as a fallback for platforms not explicitly listed.
{
"phpcs_executable_path": {
"windows": "c:\\xampp\\php\\bin\\phpcs",
"linux": "/usr/bin/phpcs",
"osx": "/usr/local/bin/phpcs"
},
"php_cs_fixer_executable_path": {
"windows": "c:\\xampp\\php\\bin\\php-cs-fixer",
"default": "/usr/local/bin/php-cs-fixer"
},
"phpcs_php_prefix_path": {
"windows": "c:\\xampp\\php\\bin\\php",
"default": ""
}
}
This works for all path settings: phpcs_executable_path, phpcs_php_prefix_path, phpcs_php_path, php_cs_fixer_executable_path, phpcbf_executable_path, and phpmd_executable_path. Plain string values continue to work as before.
All string settings support Sublime Text variable expansion using the ${var} syntax. This is particularly useful for specifying project-relative config file paths. The most useful variables are:
$project_path — The path to the folder containing the .sublime-project file$folder — The full path to the first folder listed in the side barFor example, to point php-cs-fixer at a project-specific config file:
{
"settings": {
"phpcs": {
"php_cs_fixer_additional_args": {
"--config": "${project_path}/.php-cs-fixer.php"
}
}
}
}
Or to use a project-local installation of phpcs:
{
"settings": {
"phpcs": {
"phpcs_executable_path": "${folder}/vendor/bin/phpcs"
}
}
}
See the full list of available variables in the Sublime Text documentation.
$ which phpcs
/usr/local/bin/phpcs
If you have installed php-cs-fixer, phpmd or phpcs via homebrew then please make sure that you define the "_executable_path" option to the .phar application and not the wrapper script that is placed in your bin folder, as this will cause odd behaviour.
The following is a list of commands that you can bind to a keyboard shortcut:
In order to achieve this you need to add the following to one of your key bindings settings file:
{ "keys": ["ctrl+super+t"], "command": "phpcs_clear_sniffer_marks" }
To decide which "Fixer" to use, you can do:
{ "keys": ["super+k", "super+f"], "command": "phpcs_fix_this_file", "args": {"tool": "CodeBeautifier"}},
or
{ "keys": ["super+k", "super+f"], "command": "phpcs_fix_this_file", "args": {"tool": "Fixer"}},
You can then change the ctrl+super+t combination to something of your choosing.
🔍 PHP CodeSniffer, PHP Coding Standard Fixer, Linter, and Mess Detector Support for Sublime Text
Python
807
182 commits
updated Mar 18, 2026
This is a plugin for Sublime Text which provides checkstyle reports using the following tools (all optional):
phpcs)php -l)phpmd)You can also configure the plugin to fix the issues using either
Requirements for this plugin, should you want all the options to work:
This plugin has been tested on:
It may work with other versions, but we cannot confirm that.
Use Sublime Text’s Package Control (Tools -> Command Palette -> Package Control: Install Package -> Phpcs) to install this plugin. This is the recommended installation path.
Or
Simply checkout the git repo into “~/Library/Application Support/Sublime Text/Packages/ or the equivalent folder on Windows or Linux.
cd ~/Library/Application\ Support/Sublime\ Text/Packages/
git clone git://github.com/benmatselby/sublime-phpcs.git Phpcs
In both cases, you may need to then configure the following with the actual path to the application:
They are optional for the plugin. The path needs to include the application such as /usr/local/bin/phpcs.
In order to get the path of the application (On a Mac/Linux based environment), you can use:
which phpcs
which phpmd
which php-cs-fixer
which phpcbf
Once you have right clicked on a file and selected “PHP CodeSniffer” > “Sniff this file…” you will get the output as shown below (depending on the settings you have defined):
You can also define the configuration for the following settings, be it for a project, user settings or the default settings:
show_debug – Do you want the debug information to be sent to the console?extensions_to_execute – Which filetypes do you want the plugin to execute for?extensions_to_blacklist – Override the extensions_to_execute in case you have a sub extension such as twig.php etc.phpcs_execute_on_save – Do you want the code sniffer plugin to run on file save for php files?phpcs_show_errors_on_save – Do you want the errors to be displayed in quick_panel on save?phpcs_show_gutter_marks – Do you want the errors to be displayed in the gutter?phpcs_outline_for_errors – Do you want the errors to be highlighted in the editor?phpcs_show_errors_in_status – Do you want the errors to be displayed in status bar when clicking on the line with error?phpcs_show_quick_panel – Do you want the errors to be displayed in the quick panel?phpcs_php_prefix_path – Needed on windows for phar based applications. Also if you cannot make phar executable. Avoid if possiblephpcs_commands_to_php_prefix – List of commands you want the php path to prefix. This would be useful, if you have some commands as a phar that cannot be run without the php prefix, and others using native command.phpcs_icon_scope_color - What colour to stylise the icon. This needs knowledge of theming of Sublime Test, as it uses scope colours from the theme to “tint” the dot icon. See herephpcs_sniffer_run – Do you want the PHPCS checker to run?phpcs_command_on_save – Do you want the command to execute on save?phpcs_executable_path – The path to the phpcs executable. If empty string, use PATH to find itphpcs_additional_args – This is the extra information you want to pass to the phpcs command. For example which “standard” you want to run, and if you want to show warnings or notphp_cs_fixer_on_save – Do you want to run the fixer on file save?php_cs_fixer_show_quick_panel – Do you want the quick panel to display on execution?php_cs_fixer_executable_path – The path to the php-cs-fixer application.php_cs_fixer_additional_args – This is the extra information you want to pass to the php-cs-fixer command. For example which “fixers” you want to run
"--cache-file": "${project_path}/php-cs-fixer.cache", or equivalent for your project.phpcbf_on_save – Do you want to run the fixer on file save?phpcbf_show_quick_panel – Do you want the quick panel to display on execution?phpcbf_executable_path – The path to the phpcbf application.phpcbf_additional_args – This is the extra information you want to pass to the phpcbf command. For example which “standard” to use in order to fix the issuesphpcs_linter_run – Do you want the PHP linter to run?phpcs_linter_command_on_save – Do you want the command to execute on save?phpcs_php_path – The path to the PHP executable. If empty string, use PATH to find itphpcs_linter_regex – The regex for the PHP linter outputphpmd_run – Do you want the PHPMD to run? Off by defaultphpmd_command_on_save – Do you want the command to execute on save?phpmd_executable_path – The path to the phpmd executable. If empty string, use PATH to find itphpmd_additional_args – This is the extra information you want to pass to the phpmd command. For example which “rulesets” you want to runYour .project file should look something like this:
{
"folders": [{}],
"settings": {
"phpcs": {
"phpcs_additional_args": {
"--standard": "/path/to/.composer/vendor/drupal/coder/coder_sniffer/Drupal"
}
}
}
}
Of course, this is an example of how to apply Drupal standards for the Code Sniffer. This could be anything. Whatever you can have on this package settings it can be overwritten under the settings -> phpcs.
If you use this plugin across multiple operating systems (e.g. syncing settings between Windows and Linux), you can specify platform-specific values for any path setting by using a dictionary instead of a string. The supported platform keys are "windows", "linux", and "osx". You can also specify a "default" key as a fallback for platforms not explicitly listed.
{
"phpcs_executable_path": {
"windows": "c:\\xampp\\php\\bin\\phpcs",
"linux": "/usr/bin/phpcs",
"osx": "/usr/local/bin/phpcs"
},
"php_cs_fixer_executable_path": {
"windows": "c:\\xampp\\php\\bin\\php-cs-fixer",
"default": "/usr/local/bin/php-cs-fixer"
},
"phpcs_php_prefix_path": {
"windows": "c:\\xampp\\php\\bin\\php",
"default": ""
}
}
This works for all path settings: phpcs_executable_path, phpcs_php_prefix_path, phpcs_php_path, php_cs_fixer_executable_path, phpcbf_executable_path, and phpmd_executable_path. Plain string values continue to work as before.
All string settings support Sublime Text variable expansion using the ${var} syntax. This is particularly useful for specifying project-relative config file paths. The most useful variables are:
$project_path — The path to the folder containing the .sublime-project file$folder — The full path to the first folder listed in the side barFor example, to point php-cs-fixer at a project-specific config file:
{
"settings": {
"phpcs": {
"php_cs_fixer_additional_args": {
"--config": "${project_path}/.php-cs-fixer.php"
}
}
}
}
Or to use a project-local installation of phpcs:
{
"settings": {
"phpcs": {
"phpcs_executable_path": "${folder}/vendor/bin/phpcs"
}
}
}
See the full list of available variables in the Sublime Text documentation.
$ which phpcs
/usr/local/bin/phpcs
If you have installed php-cs-fixer, phpmd or phpcs via homebrew then please make sure that you define the "_executable_path" option to the .phar application and not the wrapper script that is placed in your bin folder, as this will cause odd behaviour.
The following is a list of commands that you can bind to a keyboard shortcut:
In order to achieve this you need to add the following to one of your key bindings settings file:
{ "keys": ["ctrl+super+t"], "command": "phpcs_clear_sniffer_marks" }
To decide which "Fixer" to use, you can do:
{ "keys": ["super+k", "super+f"], "command": "phpcs_fix_this_file", "args": {"tool": "CodeBeautifier"}},
or
{ "keys": ["super+k", "super+f"], "command": "phpcs_fix_this_file", "args": {"tool": "Fixer"}},
You can then change the ctrl+super+t combination to something of your choosing.