简介
开发多年一直没有打断点的习惯,前几天被说了,于是安装了相关插件,在此做个笔记
Xdebug下载安装
- 首先要去Xdebug的官网去下载source包
- 首先要解压下载好的source包(tar -zxvf xsdebug***)
- 进入目录(phpize)
- 运行./configure,可手动指定php的配置路径(./configure --enable-xdebug --with-php-config=/usr/local/php-7.2.4/bin/php-config)
- 运行make && make install
- 成功安装后按提示在php.ini中配置(以下是我本地的相关配置,便于大家参考,zend_extension=xdebug.so之前是extension=xdebug.so,但会报错,此配置)
zend_extension=xdebug.so
[Xdebug]
#xdebug 监听端口
xdebug.remote_port = 9999
#是否开启远程调试
xdebug.remote_enable = on
xdebug.remote_autostart = 1
#远程调试的域名
#xdebug.remote_host = http://www.httouch.cn/
xdebug.remote_connect_back = 1
#远程调试的处理方式
xdebug.remote_handler = dbgp
#xdebug 会话标识, 任意配置
xdebug.idekey = vscode-xdebug
xdebug.collect_params = 1
xdebug.collect_return = 1
xdebug.auto_trace = 0
xdebug.profiler_enable = 0
xdebug.max_nesting_level = 1000000
xdebug.remote_log = /var/log/xdebug.log
- 配置成功后重启php,执行php -m查看是否安装成功
本地VScode配置
- 应用中搜索php debug(安装第一个扩展)
- 修改launch.json中内容
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"stopOnEntry":false,
"localSourceRoot": "${workspaceRoot}",
"serverSourceRoot": "/data/www/HTTouch", //虚拟机中项目路径
"port": 9999
}
- 至此一切准备就绪,f5运行,并打开断点页面