小伙伴们有木有在用st3呢? 现在的st3是愈来愈好用了,但是在编写代码时默认是不会检查代码错误的 ,今天本菜鸟网上找了下大神贴,使用SublimeLinter进行PHP代码检查 .
要实现此功能我首先需要下载 sublimelinter 和 SublimeLinter-php (具体方法度娘很多),现在只简单说下:st3中按下快捷键 ctrl+shift+p,然后输入install,选择Install Package,然后输入 sublimelinter 找到下拉列表中的插件回车安装!另一个同理.
下面介绍下SublimeLinter配置.依次点击Preferences->Package Settings->SublimeLinter->Settings 。(如果User为空复制一份 Default中的内容到 User)
请看下图
这里的 lint_mode 我设置成 ‘save only’,即保存(Ctrl+s)时进行php代码检查
成功截图:
最后附上我的配置(路径相关请自行修改<搜索paths,找到下面的windows,配置php的绝对路径,记住路径不要写到php.exe,只到php.exe所在目录就行>):
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "save only",
"linters": {
"php": {
"@disable": false,
"args": [],
"excludes": []
}
},
"mark_style": "outline",
"no_column_highlights_line": false,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": [
"G:\\xampp\\php"
]
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"javascript (babel)": "javascript",
"magicpython": "python",
"php": "html",
"python django": "python",
"pythonimproved": "python"
},
"tooltip_fontsize": "1rem",
"tooltip_theme": "Packages/SublimeLinter/tooltip-themes/Default/Default.tooltip-theme",
"tooltip_theme_excludes": [],
"tooltips": false,
"warning_color": "DDB700",
"wrap_find": true
}
}
希望此文能帮助小伙伴们节省点时间^@^