安装
- 【推荐】使用
pecl
安装Xdebug
pecl install xdebug
【手动安装】
-
Xdebug
插件下载地址:https://xdebug.org/download.php -
如果你不想考虑自己该使用哪个版本,可以使用在线工具:https://xdebug.org/wizard.php
访问环境的phpinfo
页面,将内容复制到工具页的输入框,点击分析即可。 -
编译安装
tar -xzf xdebug-***.tgz
cd xdebug-***
phpize
./configure --enable-xdebug
make
make install
配置
首先我们要在php.ini
中加载并配置插件
;php.ini配置参考
[xdebug]
; 模块文件地址
zend_extension=xdebug.so
; 远程调试开关 bool 0/1 on/off
xdebug.remote_enable = On
; 自动触发Debug,从而无需在请求中带指定参数触发
xdebug.remote_autostart = 1
; 协议 默认: dbgp
xdebug.remote_handler = "dbgp"
; 设置回连,Xdebug将尝试连接到HTTP请求的源主机地址,从而无需指定xdebug.remote_host
;xdebug.remote_connect_back = 1
; 调试host(调试客户端即IDE所在主机的host,要可以被服务器连接到)
xdebug.remote_host = "192.168.88.78"
; 调试端口(调试客户端的监听端口,即IDE设置的DebugPort)
xdebug.remote_port = 9010
; IDE调试key
xdebug.idekey = PHPSTORM
然后我们打开PhpStorm设置
配置Xdebug
本地调试项目配置
image.png
远程调试项目配置,勾选路径对应
image.png
使用
在IDE开启监听模式,在需要的代码行打上断点。代码执行到断点即会暂停,IDE会弹出Debug窗口
image.png
有的版本是这个图标
image.png
网友评论