【发布时间】:2019-09-03 04:25:02
【问题描述】:
我需要在我的本地环境中调试代码。准确地说,是我mac中的一个Laradock。但是我试了很多次都失败了。
Mac version MoJave 10.14.2
Docker version 18.09.0, build 4d60db4
Docker-compose version 1.23.2, build 1110ad01
Laradock version(commit id) a03c225e279910b9393b5e95fbffe5081b9e5a95
PhpStorm version 2018.1.1 Build #PS-181.4445.72
Xdebug 状态:
PHP 7.2.15 (cli) (built: Feb 21 2019 23:48:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.15, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans
php信息:
工作区/xdebug.ini:
php-fpm/xdebug.ini :
docker-composer ps:
PhpStorm 中的 Xdebug 设置:
PhpStorm 中的服务设置:
PhpStorm 中的远程调试设置:
PhpStorm 中的 PHP 网页设置:
以上都是我的配置信息。
我们来看看端口信息
➜ laradock git:(master) lsof -i:9001
开始监听 PHP 调试连接
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 56u IPv4 0xa71f266f59200b2d 0t0 TCP *:etlservicemgr (LISTEN)
当我输入 URL 并按 Enter 键时,窗口将跳转到 PhpStorm
PhpStorm 像这样:
当我点击'Step Over(F8)' PhpStorm 像这样:
无法继续调试,Chrome 处于等待状态:
端口信息:
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 56u IPv4 0xa71f266f59200b2d 0t0 TCP *:etlservicemgr (LISTEN)
phpstorm 268 lightWay 71u IPv4 0xa71f266f59f45e2d 0t0 TCP localhost:etlservicemgr->localhost:51955 (CLOSE_WAIT)
phpstorm 268 lightWay 73u IPv4 0xa71f266f669227ad 0t0 TCP localhost:etlservicemgr->localhost:55017 (ESTABLISHED)
com.docke 648 lightWay 30u IPv4 0xa71f266f592027ad 0t0 TCP localhost:55017->localhost:etlservicemgr (ESTABLISHED)
如果我结束浏览器访问,我会得到:
端口信息:
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 56u IPv4 0xa71f266f59200b2d 0t0 TCP *:etlservicemgr (LISTEN)
phpstorm 268 lightWay 71u IPv4 0xa71f266f59f45e2d 0t0 TCP localhost:etlservicemgr->localhost:51955 (CLOSE_WAIT)
phpstorm 268 lightWay 73u IPv4 0xa71f266f669227ad 0t0 TCP localhost:etlservicemgr->localhost:55017 (ESTABLISHED)
com.docke 648 lightWay 30u IPv4 0xa71f266f592027ad 0t0 TCP localhost:55017->localhost:etlservicemgr (ESTABLISHED)
没有任何变化,Xdebug 连接也没有中断。
但如果我点击“停止 index.php (F12)”,我的浏览器请求将结束。
这样的端口:
➜ laradock git:(master) lsof -i:9001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
phpstorm 268 lightWay 17u IPv4 0xa71f266f68032e2d 0t0 TCP *:etlservicemgr (LISTEN)
感觉PhpStorm没有收到浏览器或者Xdebug的请求。
如何让 Xdebug 工作?
哦,是的,有时我可以从 PhpStorm 获得提示
但是我已经在./laradock/.env文件中配置好了。
任何帮助将不胜感激...如果我需要提供更多信息,我很乐意提供。
【问题讨论】:
-
你的 PhpStorm 版本是多少?
-
尝试设置
xdebug.remote_connect_back = 1 -
@LazyOne PhpStorm 2018.1.1 Build #PS-181.4445.72,于 2018 年 4 月 9 日构建
-
您使用的是 Xdebug 2.7。该版本的协议有一些变化..所以你需要 PhpStorm 2018.3 或更高版本才能使用 Xdebug 2.7。或者,将 Xdebug 降级到 2.6.x。
-
@LazyOne 这太棒了! ! !没想到是XDEBUG版本的问题,谢谢老哥
标签: php laravel phpstorm xdebug laradock