最全面的sublime下配置 phpcs 攻略

1、下载php code sniffer插件安装包 地址 https://github.com/benmatselby/sublime-phpcs;

解压安装包得到sublime-phpcs-master,把sublime-phpcs-master文件夹放到sublime安装目录下的Data/Packages/目录下;重启sublime, 打开Sublime Text 3->Preferences->Package Settings -> Php Code Sniffer 证明插件安装成功;

2、第二步:下载php-cs-fixer.phar 地址 http://cs.sensiolabs.org/get/php-cs-fixer.phar   ;

3、把php-cs-fixer.phar 放到你的 php.exe 安装目录 (例如(mine is C:/WAMP/php/php.exe));

4、下载phpcs 最好从官网下载,解压,然后找到scripts目录下的phpcs.bat,放到php.exe 安装目录;

5、修改phpcs.bat 用编辑器打开。傻瓜配置

6、重点来了。下面的配置可以一定要注意路径的地址、以下是我的配置信息

{


// Path to php on windows installation

// This is needed as we cannot run phars on windows, so we run it through php

"phpcs_php_prefix_path": "E:\\php\\php.exe",


// This is the path to the bat file when we installed PHP_CodeSniffer

"phpcs_executable_path": "E:\\php\\phpcs.bat",


// PHP-CS-Fixer settings

// Don't want to auto fix issue with php-cs-fixer

"php_cs_fixer_on_save": true,


// Show the quick panel

"php_cs_fixer_show_quick_panel": true,


// The fixer phar file is stored here:

"php_cs_fixer_executable_path": "E:\\php\\php-cs-fixer.phar",


// PHP Linter settings

// Yes, lets lint the files

"phpcs_linter_run": true,


// And execute that on each file when saved (php only as per extensions_to_execute)

"phpcs_linter_command_on_save": true,


// Path to php

"phpcs_php_path": "E:\\php\\php.exe",


// This is the regex format of the errors

"phpcs_linter_regex": "(?P<message>.*) on line (?P<line>\\d+)",



// PHP Mess Detector settings

// Not turning on the mess detector here

"phpmd_run": false,

"phpmd_command_on_save" : false,

"phpmd_executable_path" : "",

"phpcs_additional_args": {

        "--standard": "JJ",

        "-n": ""

    }


}


你可能感兴趣的:(最全面的sublime下配置 phpcs 攻略)