如何配置Sublime Text 3中的php语法错误提示插件

发布时间:2020-07-16 14:22:40 作者:Leah
来源:亿速云 阅读:319

如何配置Sublime Text 3中的php语法错误提示插件?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

Sublime Text 3配置php语法错误提示插件的方法:首先下载sniffer插件安装包;然后下载插件并放到php.exe安装目录里;接着设置都改成本地环境下的php安装路径;最后保存,重启Sublime Text 3即可。

Sublime Text 3配置php语法错误提示插件的方法:

第一步:下载php code sniffer插件安装包

解压安装包得到sublime-phpcs-master,把sublime-phpcs-master文件夹放到sublime安装目录下的Data/Packages/目录下;

重启sublime, 打开Sublime Text 3->Preferences->Package Settings -> Php Code Sniffer 证明插件安装成功;

第二步:下载php-cs-fixer.phar

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

第四步:下载 http://download.pear.php.net/package/PHP_CodeSniffer-1.5.0RC4.tgz,解压,然后找到scripts目录下的phpcs.bat,放到php.exe 安装目录;

第五步:解压打开,在子文件example-settings下有个文件

windows-7-phpcs-fixer-linter.example就是Sublime Text 3 在windows7配置 PHPCS 的样例,还有一个nix-all-commands.example是在linux/unix环境下的配置样例

第六步:以下就是windows-7-phpcs-fixer-linter.example的配置内容,打开你的Sublime Text 3->Preferences->Package Settings -> Php Code Sniffer -> Settings - User ,复制windows-7-phpcs-fixer-linter.example的内容到配置文件phpcs.sublime-settings,然后修改对应的php.exe路径

设置都改成你本地环境下的php安装路径,保存,重启Sublime Text 3

{
// 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": "C:\\wamp\\bin\\php\\php5.4.12\\php.exe",
// This is the path to the bat file when we installed PHP_CodeSniffer
"phpcs_executable_path": "C:\\wamp\\bin\\php\\php5.4.12\\phpcs.bat",
// PHP-CS-Fixer settings
// Don't want to auto fix issue with php-cs-fixer
"php_cs_fixer_on_save": false,
// Show the quick panel
"php_cs_fixer_show_quick_panel": true,
// The fixer phar file is stored here:
"php_cs_fixer_executable_path": "C:\\wamp\\bin\\php\\php5.4.12\\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": "C:\\wamp\\bin\\php\\php5.4.12\\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": "",
"phpmd_additional_args": {}
}

重启Sublime Text 3,打开php程序,语法错误提示如下图:

如何配置Sublime Text 3中的php语法错误提示插件


看完上述内容,你们掌握如何配置Sublime Text 3中的php语法错误提示插件的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. sublime常用配置
  2. Sublime Text 3 配置

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

sublime php te

上一篇:日历控件

下一篇:还原PostgreSQL中.bak文件的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》