This should be enough, save everything and create your Run/Debug configuration using this CLI interpreter. choose “Connect to existing container” instead of starting a new one.choose Docker Compose Configuration files in my case I choose two in following order:.select or create new Server (use Unix socket to connect to Docker daemon).in new window add a new interpreter “From Docker, Vagrant, VM, Remote…”.
in your PhpStorm Settings go to Languages and Frameworks > PHP and click the ‘…’ button near the “CLI Interpreter” field.I will not describe the whole Run/Debug configurations topic here but only one Docker-specific aspect: you need to teach your PhpStorm to run PHP interpreter inside your container.įor this you need to create a new PHP CLI interpreter configuration: Sometimes it is useful to create and store some specific configuration so you can run it over and over. Creating Run/Debug configurations in PhpStorm If you don’t like this approach, just disable the autostart and start the session your own way (see: Activate debugger). I believe this still adds a small overhead in time for all requests, but for me it is unnoticeable. So when I don’t need to debug, I just switch listening off. The case is that when XDebug tries to start the debugging session but the remote host is not listening, the XDebug does not continue. However I found it convenient to enable autostart and only control the XDebug via PhpStorm. Normally you would need a browser extension, which adds debug session start flag to your requests when you need it. One important thing you need to do is to start listening for PHP debug connections with a small phone icon in your PhpStorm.
Phpstorm xdebug docker code#
Then on the same host as VSCode you could then. Make sure VSCode is listening for connections, and that you have a script with a breakpoint in it ready to run. This includes running all of this on localhost, OR running VSCode and PHP in WSL2. Increase default maximal function nesting level, because it is often not enough. The default config for listening for Xdebug will work in most situations.Enable automatic start on every request (see note on this below).& echo "zend_extension= $(find $(php-config -extension-dir) -name xdebug.so)" \ Add Xdebug to your PHP application containerĪdd following lines to your php Dockerfile: 1