Xdebug in phpstorm and docker

I managed to get xdebug in combination with docker and phpstorm. For http calls ... IE

http://192.168.99.100:8081/?XDEBUG_SESSION_START=PHPSTORM

But when I try to run phpunit tests, it does not connect to phpstorm

I did the directory mapping correctly in phpstorm and also did the following on my docker instance export XDEBUG_CONFIG="idekey=PHPSTORM"

I also tried on my docker: export PHP_IDE_CONFIG = 'serverName = web.docker'and named the server configuration on phpstorm web.docker. still working on http but not CLI

Can I get phpstorm and xdebug to work together for the command line?

here is my file: /etc/php5/cli/conf.d/20-xdebug.ini

 zend_extension=xdebug.so xdebug.remote_enable=1 xdebug.idekey=PHPSTORM xdebug.remote_connect_back=1 xdebug.remote_host=172.17.42.1 dxdebug.remote_autostart=1 

When I turn on logging and play with the xdebug_remote_host IP address, I get

 W: Remote address not found, connecting to configured address/port: localhost:9000. :-| E: Could not connect to client. :-( Log closed at 2015-10-13 12:20:39 Log opened at 2015-10-13 12:22:58 I: Checking remote connect back address. W: Remote address not found, connecting to configured address/port: 172.17.42.1:9000. :-| E: Could not connect to client. :-( Log closed at 2015-10-13 12:22:58 Log opened at 2015-10-13 12:23:58 I: Checking remote connect back address. W: Remote address not found, connecting to configured address/port: 192.168.99.100:9000. :-| E: Could not connect to client. :-( Log closed at 2015-10-13 12:23:58 

Solution (change) Turning on xdebug logging, I saw that it successfully connects to 192.168.99.1 , so this solved the problem

 xdebug.remote_host=192.168.99.1 
+5
source share
3 answers

Now two things come to my mind:

  • Is xdebug.remote_host installed correctly? For the HTTP link, you specified the address 192.168. to return the address 172.17. back 172.17. . Can you ping your host on this IP?

  • In your ini file it reads:

     dxdebug.remote_autostart=1 

    Is it just a typo here, or is it really in your configuration file? Because he must read xdebug without the "d" in front of him. It should be:

     xdebug.remote_autostart=1 

    You should add d only when adding an option when running the script as follows:

     php -dxdebug.remote_autostart=1 script.php 

If this still does not help, enable the remote log by adding something like this to the configuration:

 xdebug.remote_log = /var/log/xdebug_remote.log 

perhaps this will help find the problem.

+4
source

What worked for me is an ssh tunnel with this configuration xdebug.remote_connect_back = 0 xdebug.remote_host = 127.0.0.1

See: Xdebug with SSH tunnel on Docker for Mac

+1
source

With Docker-17.06, you can access services hosted on a Mac inside Container through a static hostname: docker.for.mac.localhost

full answer here: fooobar.com/questions/1233354 / ...

0
source

Source: https://habr.com/ru/post/1233351/


All Articles