{"id":13536426,"url":"https://github.com/benmatselby/sublime-phpcs","last_synced_at":"2025-08-13T04:18:27.333Z","repository":{"id":2428857,"uuid":"3398115","full_name":"benmatselby/sublime-phpcs","owner":"benmatselby","description":"🔍 PHP CodeSniffer, PHP Coding Standard Fixer, Linter, and Mess Detector Support for Sublime Text","archived":false,"fork":false,"pushed_at":"2023-10-18T09:51:31.000Z","size":144,"stargazers_count":812,"open_issues_count":13,"forks_count":126,"subscribers_count":28,"default_branch":"main","last_synced_at":"2024-11-03T01:33:12.332Z","etag":null,"topics":["fixer","linter","php-codesniffer","phpcs","phpmd","sublime-text","sublime-text-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"alexdu/piggyphoto","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benmatselby.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-02-09T15:19:25.000Z","updated_at":"2024-09-27T02:47:15.000Z","dependencies_parsed_at":"2022-08-06T12:15:20.767Z","dependency_job_id":"fdeb4254-b7cd-4d23-8148-22ed87a50db6","html_url":"https://github.com/benmatselby/sublime-phpcs","commit_stats":{"total_commits":160,"total_committers":26,"mean_commits":6.153846153846154,"dds":"0.23124999999999996","last_synced_commit":"6aa6816963c4fc79dcceee507b2f8049c1a4f8be"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmatselby%2Fsublime-phpcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmatselby%2Fsublime-phpcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmatselby%2Fsublime-phpcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmatselby%2Fsublime-phpcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benmatselby","download_url":"https://codeload.github.com/benmatselby/sublime-phpcs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246750843,"owners_count":20827790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fixer","linter","php-codesniffer","phpcs","phpmd","sublime-text","sublime-text-plugin"],"created_at":"2024-08-01T09:00:39.081Z","updated_at":"2025-04-02T03:30:44.318Z","avatar_url":"https://github.com/benmatselby.png","language":"Python","readme":"# sublime-phpcs\n\nThis is a plugin for Sublime Text which provides checkstyle reports using the following tools (all optional):\n\n- PHP_CodeSniffer (`phpcs`)\n- Linter (`php -l`)\n- PHP Mess Detector (`phpmd`)\n\nYou can also configure the plugin to fix the issues using either\n\n- PHP Coding Standards Fixer (php-cs-fixer)\n- PHP Code Beautifier (phpcbf) application\n\n## Requirements\n\nRequirements for this plugin, should you want all the options to work:\n\n- [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)  3.5+\n- [PHPMD](https://phpmd.org) 2.8+\n- [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) 2.6+\n\nThis plugin has been tested on:\n\n- Mac OS X 10.8.2\n- Ubuntu 11.10\n- Windows 7\n- Sublime Text 2\n- Sublime Text 3\n- Sublime Text 4\n\nIt may work with other versions, but we cannot confirm that.\n\n## Installation\n\nUse Sublime Text’s Package Control (Tools -\u003e Command Palette -\u003e Package Control: Install Package -\u003e Phpcs) to install this plugin. This is the recommended installation path.\n\nOr\n\nSimply checkout the git repo into “~/Library/Application Support/Sublime Text/Packages/ or the equivalent folder on Windows or Linux.\n\n```shell\ncd ~/Library/Application\\ Support/Sublime\\ Text/Packages/\ngit clone git://github.com/benmatselby/sublime-phpcs.git Phpcs\n```\n\nIn both cases, you may need to then configure the following with the actual path to the application:\n\n- “phpcs_php_path”\n- “phpcs_executable_path”\n- “phpmd_executable_path”\n- “php_cs_fixer_executable_path”\n\nThey are optional for the plugin. The path needs to include the application such as `/usr/local/bin/phpcs`.\n\nIn order to get the path of the application (On a Mac/Linux based environment), you can use:\n\n```shell\nwhich phpcs\nwhich phpmd\nwhich php-cs-fixer\nwhich phpcbf\n```\n\n## Features\n\n- Ability to run PHP_CodeSniffer\n- Ability to run php -l on the open file\n- Ability to run PHP Mess Detector on the open file\n- Show cached results from PHP_CodeSniffer in open file\n- Show errors in the Quick Panel\n- Show errors in the Gutter\n- Highlight the errors in the editor\n- Show the error for a given line in the status bar\n- Ability to specify the regular expression of the linter errors\n- Ability to specify the location of the PHP_CodeSniffer application\n- Ability to specify the location of the PHP Mess Detector application\n- Ability to run the PHP Coding Standards Fixer tool which fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents\n- Ability to run the PHP Code Beautifier tool which fixes most issues in your code when you want to follow PHP coding standards\n\nOnce you have right clicked on a file and selected “PHP CodeSniffer” \u003e “Sniff this file…” you will get the output as shown below (depending on the settings you have defined):\n\n## Configuration\n\nYou can also define the configuration for the following settings, be it for a project, user settings or the default settings:\n\n### Plugin\n\n- `show_debug` – Do you want the debug information to be sent to the console?\n- `extensions_to_execute` – Which filetypes do you want the plugin to execute for?\n- `extensions_to_blacklist` – Override the extensions_to_execute in case you have a sub extension such as twig.php etc.\n- `phpcs_execute_on_save` – Do you want the code sniffer plugin to run on file save for php files?\n- `phpcs_show_errors_on_save` – Do you want the errors to be displayed in quick_panel on save?\n- `phpcs_show_gutter_marks` – Do you want the errors to be displayed in the gutter?\n- `phpcs_outline_for_errors` – Do you want the errors to be highlighted in the editor?\n- `phpcs_show_errors_in_status` – Do you want the errors to be displayed in status bar when clicking on the line with error?\n- `phpcs_show_quick_panel` – Do you want the errors to be displayed in the quick panel?\n- `phpcs_php_prefix_path` – Needed on windows for phar based applications. Also if you cannot make phar executable. Avoid if possible\n- `phpcs_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.\n- `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 here\n\n### PHP_CodeSniffer\n\n- `phpcs_sniffer_run` – Do you want the PHPCS checker to run?\n- `phpcs_command_on_save` – Do you want the command to execute on save?\n- `phpcs_executable_path` – The path to the phpcs executable. If empty string, use PATH to find it\n- `phpcs_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 not\n\n### PHP CodeSniffer Fixer\n\n- `php_cs_fixer_on_save` – Do you want to run the fixer on file save?\n- `php_cs_fixer_show_quick_panel` – Do you want the quick panel to display on execution?\n- `php_cs_fixer_executable_path` – The path to the php-cs-fixer application.\n- `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\n\n### PHP Code Beautifier\n\n- `phpcbf_on_save` – Do you want to run the fixer on file save?\n- `phpcbf_show_quick_panel` – Do you want the quick panel to display on execution?\n- `phpcbf_executable_path` – The path to the phpcbf application.\n- `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 issues\n\n### PHP Linter\n\n- `phpcs_linter_run` – Do you want the PHP linter to run?\n- `phpcs_linter_command_on_save` – Do you want the command to execute on save?\n- `phpcs_php_path` – The path to the PHP executable. If empty string, use PATH to find it\n- `phpcs_linter_regex` – The regex for the PHP linter output\n\n### PHP Mess Detector\n\n- `phpmd_run` – Do you want the PHPMD to run? Off by default\n- `phpmd_command_on_save` – Do you want the command to execute on save?\n- `phpmd_executable_path` – The path to the phpmd executable. If empty string, use PATH to find it\n- `phpmd_additional_args` – This is the extra information you want to pass to the phpmd command. For example which “rulesets” you want to run\n\n### Project Based Settings\n\nYour .project file should look something like this:\n\n```json\n{\n  \"folders\": [{}],\n  \"settings\": {\n    \"phpcs\": {\n      \"phpcs_additional_args\": {\n        \"--standard\": \"/path/to/.composer/vendor/drupal/coder/coder_sniffer/Drupal\"\n      }\n    }\n  }\n}\n```\n\nOf course this is a example to apply Drupal code sniffer. This could be anything. Whatever you can have on this package settings it can be overwritten under the settings -\u003e phpcs\n\n## FAQ\n\n### What do I do when I get \"OSError: [Errno 8] Exec format error\"?\n\n- This seems to be an issue you may get with regards to wrapper scripts.\n- Please make sure that the application/script you are referencing has the correct shebang line, as per [GH-79](https://github.com/benmatselby/sublime-phpcs/issues/79)\n\n### What do I do when I get \"OSError: [Error 2] No such file or directory\"?\n\n- Well, first of all you need to check that you have PHP_CodeSniffer, and if being used, the phpmd application.\n- If you have these applications installed, then it sounds like those applications are not in your PATH, or cannot be found in your PATH by the Python runtime, so configure \"phpcs_php_path\", \"phpcs_executable_path\", \"phpmd_executable_path\" and \"php_cs_fixer_executable_path\" with the actual paths to those applications\n\n### What do I do when I get \"OSError: [Errno 13] Permission denied\"?\n\n- It sounds like your path settings are incorrect.\n- You need to make sure that when you specifiy the path you include the entire path including the application\n\n```shell\n$ which phpcs\n/usr/local/bin/phpcs\n```\n\n- That entire output is the path you need in your configs.\n\n### What if I've installed the applications using Homebrew?\n\nIf 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.\n\n### What other Key Bindings can I setup?\n\nThe following is a list of commands that you can bind to a keyboard shortcut:\n\n- phpcs_fix_this_file\n- phpcs_clear_sniffer_marks\n- phpcs_goto_next_error\n- phpcs_show_previous_errors\n- phpcs_sniff_this_file\n\nIn order to achieve this you need to add the following to one of your key bindings settings file:\n\n```json\n{ \"keys\": [\"ctrl+super+t\"], \"command\": \"phpcs_clear_sniffer_marks\" }\n```\n\nTo decide which \"Fixer\" to use, you can do:\n\n```json\n{ \"keys\": [\"super+k\", \"super+f\"], \"command\": \"phpcs_fix_this_file\", \"args\": {\"tool\": \"CodeBeautifier\"}},\n```\n\nor\n\n```json\n{ \"keys\": [\"super+k\", \"super+f\"], \"command\": \"phpcs_fix_this_file\", \"args\": {\"tool\": \"Fixer\"}},\n```\n\nYou can then change the ctrl+super+t combination to something of your choosing.\n","funding_links":[],"categories":["Python","PHP相关软件/工具"],"sub_categories":["PRC"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmatselby%2Fsublime-phpcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenmatselby%2Fsublime-phpcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmatselby%2Fsublime-phpcs/lists"}