phpStorm 配置 xdebug 详细配置
2020-05-25 本文已影响0人
PHP的点滴
在PHP开发过程中,经常使用断点调试,最简单的方式就是
echo、var_dump、print_r() 然后 die() 、exit();
今天我们来介绍可追踪变量的 调试方式: xdebug
1.先直观感受下,配置好后调试的情况
- 详细请求对象
- 过程中产生的变量
- 单步调试等

2.如何配置
2.1 生成xdebug扩展
根据php配置,生成对应的扩展包; https://xdebug.org/wizard

2.2 配置php.ini
extension="redis.so"
[xdebug]
zend_extension="/usr/local/lib/php/pecl/20160303/xdebug.so"
xdebug.remote_handler="dbgp"
xdebug.remote_enable=1 //注意1:是否运行远程终端,必须开启
xdebug.remote_host="localhost"
xdebug.remote_port=9001 //注意2:端口要和phpstorm中的保持一致
;xdebug.profiler_enable=1
;xdebug.idekey="PHPSTORM" //调试器关键字
2.3 配置成功后,重启php-fpm,访问phpinfo 如下:

2.4 配置PHPSTORM
-
点击左上角phpstorm,选择preferences。
image.png
-
配置 Debug 的端口
image.png
-
配置 Debug下的DBGp proxy

- 配置servers

-
配置调试地址
image.png
3.断点调试

4.配置浏览器扩展(可选)
谷歌浏览器扩展https://github.com/xdebug/xdebug
如没有梯子,则可以通过github下载后,离线安装

