vscode配合phpstudy开启xdebug调试
php程序开发,xdebug比不可少,记录下配置流程。
phpstudy
phpstudy在php环境集成的xdebug,直接将插件开启即可使用。
phpstudy->软件管理->全部->php->设置,开启xdebug调试组件,并设置端口。
vscode
在项目根目录下,建立用户自定义配置。vscode的所有配置,均在在此设置,这样,每个项目可以配置不同的环境和配色等。
.vscode/settings.json
这块写自己的开启了xdebug插件的php路径
{
"php.validate.executablePath":"*//php.exe",
"php.debug.executablePath":"*//php.exe",
"php.debug.ideKey": "vsc"
}
php.debug.executablePath
:debug调用的php环境
php.debug.ideKey
: 执行唤起ide的xdebug终端关键字,此配置需要php.ini
中配置一致。
配置此项,可忽略xdebug.remote_host
配置
php.ini
zend_extension=D:/web/serve/phpstudy_pro/Extensions/php/php7.1.9nts/ext/php_xdebug.dll
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=Off
xdebug.trace_output_dir=D:/web/serve/phpstudy_pro/Extensions/php_log/php7.1.9nts.xdebug.trace
xdebug.profiler_enable=Off
xdebug.profiler_output_dir=D:/web/serve/phpstudy_pro/Extensions/php_log/php7.1.9nts.xdebug.profiler
xdebug.remote_enable=1
xdebug.remote_autostart = 1
xdebug.idekey=vsc
;xdebug.remote_host=m.zmyy.tf
xdebug.remote_port=9100
xdebug.remote_handler=dbgp
大部分是自动生成的配置,注意idekey
、remote_host
、remote_port
三项配置即可。
配置完毕,测试效果
在需要调试的代码行打断点
按F5启动调试,vscdode会提示配置,launch.json文件,用于发起调试
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9100
},
访问php端程序,发现程序到断点处停了下来,开始愉快的调试吧。
分享一下vscode的个人配置
.vscode/settings.json
排除文件显示
{
"files.exclude": {
"**/.DS_Store": true,
"**/__init__.py": true,
"**/__pycache__": true,
},
}
代码自动换行,显示代码长度标尺线
{
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 120,
"editor.rulers": [
80,
120
],
}
编辑器的高亮配置
{
"workbench.colorCustomizations": {
// "editor.background": "#363636", //编辑器背景色
"editor.lineHighlightBackground": "#49b2b93d", //修改光标所在行的背景色
"editor.lineHighlightBorder": "#ffffff30", //修改光标所在行的边框色
"editor.selectionBackground": "#49b2b93d", //是选中后拖拉呈现的颜色
"editor.findMatchBackground": "#511F90", //当前搜索匹配的颜色
"editor.findMatchHighlightBackground": "#fd5000", //其他搜索匹配项的颜色
"editor.findRangeHighlightBackground": "#ff9900", //限制搜索范围的颜色
"list.inactiveSelectionBackground": "#008000",
},
}
编辑器代码配色自定义
{
"editor.tokenColorCustomizations": {
"comments": "#708090", //春天绿
"keywords": "#c792eaff",
"strings": "#C3E88D"
},
}
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »