一、检测需要的xdebug版本 使用网站:Xdebug: Support — Tailored Installation Instructions
可以参考这篇文章:phpStorm 安装使用xdebug断点调试流程_༺墨༒眉༻-CSDN博客
得出我们需要的版本是 3.1.3
开始安装:
pecl install http://pecl.php.net/get/xdebug-3.1.3.tgz
如果已安装则更新到指定版本
pecl upgrade http://pecl.php.net/get/xdebug-3.1.3.tgz
完整完成后php.ini 会增加一条zend_extension="xdebug.so" 的引用
尝试使用编辑器调试发现断点并没有生效,查询日志才看到报错了
查询后发现 xdebug配置xdebug2.+ 跟xdebug3.+配置不一样
可以参考文档Xdebug: Documentation » Upgrading from Xdebug 2 to 3
2.0版本配置
xdebug.remote_enable=ON
xdebug.remote_autostart=ON
xdebug.auto_trace=ON
xdebug.idekey="PHPSTORM"
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.max_nesting_level=600
xdebug.remote_port = 11011
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "/var/log/php/xdebug.log"
xdebug3版本的php.ini配置
[XDebug]
xdebug.mode = debug,trace
xdebug.start_with_request = yes
xdebug.remote_handler="dbgp"
xdebug.idekey="PHPSTORM"
xdebug.client_port = 11011
xdebug.client_host = "127.0.0.1"
xdebug.log = "/var/log/php/xdebug.log"
而xdebug.idekey则可使用环境变量常量设置,加到~/.bash_profile 文件里
export XDEBUG_SESSION=PHPSTORM
都配置完成了但是还是不断点打印。。。。
查看phpinfo发现没有打开调试
mode参数还没配置成功
乌龙了,最后才发现是我复制的代码可能存在空格之类的导致没有生效,我又重新手打了一遍成功了
修改编辑器的配置:
成功了!!!