- 下载PHP_CodeSniffer插件,下载,解压后将sublime-phpcs-master文件夹放在Packages\下,具体目录打开Sublime->Preferences->Browse Packages。
- 注意:不要从Package Controller上安装,会出错。
- 下载php-cs-fixer.phar,下载,并把它放在php.exe的安装目录,如(D:\wamp64\bin\php\php7.2.10php.exe)。
- 下载PHP_CodeSniffer,下载,解压后找到phpcs.bat,将它放在php.exe的安装目录。
- 打开Sublime,Preferences->Packages Settings->PHP Code Sniffer->Settings -User。然后把Settings -Default中的内容复制到这里,修改填上空白路径,例如:
-
{ // Plugin settings // Turn the debug output on/off "show_debug": false, // Which file types (file extensions), do you want the plugin to // execute for "extensions_to_execute": ["php"], // Do we need to blacklist any sub extensions from extensions_to_execute // An example would be ["twig.php"] "extensions_to_blacklist": [], // Execute the sniffer on file save "phpcs_execute_on_save": true, // Show the error list after save. "phpcs_show_errors_on_save": true, // Show the errors in the gutter "phpcs_show_gutter_marks": true, // Show outline for errors "phpcs_outline_for_errors": true, // Show the errors in the status bar "phpcs_show_errors_in_status": true, // Show the errors in the quick panel so you can then goto line "phpcs_show_quick_panel": true, // The path to the php executable. // Needed for windows, or anyone who doesn't/can't make phars // executable. Avoid setting this if at all possible "phpcs_php_prefix_path": "D:\\wamp64\\bin\\php\\php7.2.10\\php.exe", // Options include: // - Sniffer // - Fixer // - MessDetector // - CodeBeautifier // // This will prepend the application with the path to php // Needed for windows, or anyone who doesn't/can't make phars // executable. Avoid setting this if at all possible "phpcs_commands_to_php_prefix": [], // What color to stylise the icon // https://www.sublimetext.com/docs/3/api_reference.html#sublime.View // add_regions "phpcs_icon_scope_color": "comment", // PHP_CodeSniffer settings // Do you want to run the phpcs checker? "phpcs_sniffer_run": true, // Execute the sniffer on file save "phpcs_command_on_save": true, // It seems python/sublime cannot always find the phpcs application // If empty, then use PATH version of phpcs, else use the set value "phpcs_executable_path": "D:\\wamp64\\bin\\php\\php7.2.10\\phpcs.bat", // Additional arguments you can specify into the application // // Example: // { // "--standard": "PEAR", // "-n" // } "phpcs_additional_args": { "--standard": "PSR2", "-n": "" }, // PHP-CS-Fixer settings // Fix the issues on save "php_cs_fixer_on_save": false, // Show the quick panel "php_cs_fixer_show_quick_panel": false, // Path to where you have the php-cs-fixer installed "php_cs_fixer_executable_path": "D:\\wamp64\\bin\\php\\php7.2.10\\php-cs-fixer-v2.phar", // Additional arguments you can specify into the application "php_cs_fixer_additional_args": { }, }
- 然后重启Sublime Text 3就可以使用,如图:
转载于:https://www.cnblogs.com/eugene-21/p/9771261.html