无法使Xdebug正常工作(mac + PhpStorm + Laradock + Xdebug)

时间:2019-04-12 11:52:47

标签: php laravel phpstorm xdebug laradock

我需要在本地环境中调试代码。准确地说,是我的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

phpinfo: xdebug info in phpinfo web page

workspace / xdebug.ini: workspace/xdebug.ini

php-fpm / xdebug.ini: php-fpm/xdebug.ini

docker-composer ps: docker-composer ps

PhpStorm中的Xdebug设置: xdebug in PhpStorm setting

PhpStorm中的服务设置: service setting in PhpStorm

PhpStorm中的远程调试设置: remote debug setting in PhpStorm

PhpStorm中的PHP Web页面设置: php web page setting in PhpStorm

以上所有都是我的配置信息。

让我们看一下端口信息

➜  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像这样: phpstorm

当我单击“ Step Over(F8)” PhpStorm时,如下所示: debug failed

调试无法继续,Chrome处于等待状态: 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)

如果结束浏览器访问,我会得到:

debug failed

端口信息:

➜  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连接也没有中断。

但是,如果我单击“ Stop 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获得提示 tips

但是我已经在./laradock/.env文件中对其进行了配置。

任何帮助将不胜感激...如果我需要提供更多信息,我会很乐意这样做。

1 个答案:

答案 0 :(得分:0)

我的设置未使用PHPStorm,但尝试更改以下设置以进行匹配:

workspace / xdebug.ini 中设置:

System.Byte[]

并在 php-fpm / xdebug.ini 中设置:

xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000

请确保重建您的Docker容器(包括php-fpm)以包含所有配置更改-这是我缺少的键

xdebug.remote_host=host.docker.internal