1
votes

I need to debug the code in my local environment.Accurately speaking, is a Laradock in my mac. But I tried it many times and failed.

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 status :

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

Xdebug setting in PhpStorm : xdebug in PhpStorm setting

Service setting in PhpStorm : service setting in PhpStorm

Remote debug setting in PhpStorm : remote debug setting in PhpStorm

PHP Web Page setting in PhpStorm : php web page setting in PhpStorm

All of the above are my configuration information.

Let's take a look at the port information

➜  laradock git:(master) lsof -i:9001


Started Listening for PHP Debug connections

➜  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)

When I type in the URL and press the Enter key, the window will jump to PhpStorm

PhpStorm Like this : phpstorm

When I click 'Step Over(F8)' PhpStorm Like this: debug failed

Debugging can't go on and Chrome is waiting state: chrome

Port information :

➜  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)

If I end my browser access, I got :

debug failed

Port information :

➜  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)

Nothing changes and Xdebug Connection is not broken.

But if I click 'Stop index.php (F12)' my browser request will end.

port like this :

➜  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)

I feel that PhpStorm has not received a request from the browser or Xdebug.

How do I get the Xdebug work?

Oh, yes, sometimes I can get tips from PhpStorm tips

But I have already configured it in the ./laradock/.env file.

Any help would be greatly appreciated... If I need to supply more info, I will gladly do so.

1
What's your PhpStorm version? - LazyOne
Try to set xdebug.remote_connect_back = 1 - Tarasovych
@LazyOne PhpStorm 2018.1.1 Build #PS-181.4445.72, built on April 9, 2018 - lightWay
You are using Xdebug 2.7. That version had some changes in its protocol .. so you need PhpStorm 2018.3 or newer in order to work with Xdebug 2.7. Alternatively, downgrade Xdebug to 2.6.x. - LazyOne
@ LazyOne This is amazing! ! ! I never thought that this trouble is about XDEBUG version, thank you bro - lightWay

1 Answers

0
votes

My setup isn't using PHPStorm but try changing the following settings to match:

In workspace/xdebug.ini set:

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

And in php-fpm/xdebug.ini set:

xdebug.remote_host=host.docker.internal

Be sure to rebuild your docker container (including php-fpm) to include any config changes - this was the missing key for me:

docker-compose down
docker-compose build mysql nginx php-fpm
docker-compose up -d mysql nginx php-fpm