PHP安装xdebug扩展
我使用的docker环境,dnmp的镜像。安装xdebug的步骤:传送门
配置Xdebug
-
修改php.ini文件
zend_extension=xdebug.so xdebug.remote_enable=1 ; xdebug.remote_handler="dbgp" ; docker推荐采用如下形式表示和phpstorm所在机器的ip(如果你的phpstorm装在宿主机那就是宿主机的ip) xdebug.remote_host=host.docker.internal xdebug.remote_port=9003 xdebug.remote_log=/var/log/php/xdebug.log xdebug.idekey=PHPSTORM xdebug.mode = debug xdebug.remote_mode="req" xdebug.remote_autostart =1 ;启用代码自动跟踪 (可以不添加) xdebug.auto_trace = On ;启用性能检测分析 (可以不添加) xdebug.profiler_enable = On xdebug.profiler_enable_trigger = On xdebug.profiler_output_name = profiler.out.%t.%p
-
查看xdebug是否安装成功
配置PHPSTORM
- docker 开启tcp 2375 端口
处于安全原因,Docker Mac 客户端并没有开启 2375 端口的配置,所以我们可以用 socat 来 fork 一个端口出来。
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 bobrik/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
调试的时候这个必须是要开启的
- 创建PHP-CLI解释器
开始调试
- 开启调试
- 网页上访问, 刷新界面