Answer the question
In order to leave comments, you need to log in
How to make friends Windows 10 + Docker + PhpStorm + Xdebug?
Good afternoon!
The second day I suffer with Xdebug'a setup.
Windows 10 OS, I use Docker ("Docker for Windows") to run applications.
There was a need to debug PHP code in PhpStorm. And ran into setting up the whole thing.
My current setup.
In the docker-file for the "php-container" I install xdebug:
pecl install xdebug; \
docker-php-ext-enable xdebug; \
echo "error_reporting=E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "display_startup_errors=On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "display_errors=On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_host=10.0.75.1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
Answer the question
In order to leave comments, you need to log in
Good afternoon.
I recently described the whole process in detail on my blog. Works guaranteed.
Welcome!
https://blog.denisbondar.com/post/phpstorm_docker_...
The thing is how the network for docker under Windows is arranged, alas, you need to specify the IP address of the docker virtual adapter, otherwise no debug.
https://devilbox.readthedocs.io/en/latest/intermed...
As an example
tcp/ip level
1. Make sure that the storm listens for connections on the port (the listen debug connection icon is green)
2. Make sure that you can reach the "parent" host from the docker at the address you specified in the configuration. telnet ip port.
3. Enable xdebug logging and see what will be in the log
Remote_autostart is not needed, turn it off.
Remove remote_host and set connect_back to 1.
Also check that not only port 9000, but also 9001 is forwarded to the host.
When it works, do not forget to uncheck "force break at first line ..." in phpstorm in xdebug settings
. , so as not to write a cookie in each request to start a debug session.
I have defined for myself a universal approach for debugging in any network environment.
In the simplest case, when there is only one developer, and the server is behind NAT, you need to forward the port to the server via ssh.
At the same time, xdebug must be configured in php.ini so that it connects to localhost:9000.
When there are many developers, I use a modified dbgp proxy.
https://github.com/MadridianFox/php-xdebug-proxy
If it is on the same server as php, the xdebug settings are the same. The proxy is listening on port 9000. Each developer chooses a unique port for himself and forwards it via ssh to the server. You also need to forward port 9001 back to register your idekey in the proxy.
And most importantly - when registering your idekey through a storm, in the idekey field you need to write myidekey:9002
In the same window, the proxy port is 9001, the proxy host is localhost.
In the storm settings, we indicate that for debugging it is necessary to listen to port 9002.
In the browser, it doesn't matter if you use an extension or write XDEBUG_SESSION_START, you must specify myidekey without a port!
In the case of docker, you can either add an ssh server to a container with php itself, or raise an additional ssh container. With a single development, this is enough. Simply, depending on the location of ssh, you prescribe different hosts in xdebug. Throws a port there.
If there is more than one developer, allocate a container with ssh + dbgp proxy and each developer forwards his own port there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question