🌐
DEV Community
dev.to › jackmiras › xdebug-in-phpstorm-with-docker-2al8
Xdebug in PhpStorm with Docker - DEV Community
November 3, 2023 - Next, a form will open, and there, fill the Name with your Remote Debug configuration; next, check the Filter debug connection by IDE key option and then select the Server previously created; and finally, fill the IDE key (session id) with the same value that got used at the xdebug.idekey directive at our .docker/xdebug.ini. More details are in the illustration below: As a result of the previous steps, the remote debug configuration got finished, and PhpStorm can now start listening for PHP debug connections.
🌐
Medium
medium.com › the-sensiolabs-tech-blog › how-to-use-xdebug-in-docker-phpstorm-76d998ef2534
How to use Xdebug in Docker & PhpStorm | The SensioLabs Tech Blog
June 14, 2022 - Before going further, there is ... as I was at the end of this article. Alright, first things first, Xdebug needs to be installed in the Docker image you use....
Discussions

[solved] How to setup xdebug and phpstorm
Hello, I'm a bit confused using xdebug, docker for windows, and phpstorm... i have xdebug configured in a container with PHP. Here is what appears in my php.ini from within this container : xdebug.remote_enable=on … More on forums.docker.com
🌐 forums.docker.com
19
1
May 26, 2016
php - Using Xdebug and PhpStorm with Docker container on Windows - Stack Overflow
I am trying to make Xdebug work for Docker container on Windows with PhpStorm. I read different articles and other threads, but still it's not working. Inside docker-compose.yaml I have following More on stackoverflow.com
🌐 stackoverflow.com
phpstorm - Xdebug CLI in Docker - Stack Overflow
I read a lot of posts on GitHub and StackOverflow and I didn't find an answer. I have Docker container with PHP 7.4 and Xdebug 3. The IDE is PhpStorm. When I use Xdebug in browser, Xdebug works fin... More on stackoverflow.com
🌐 stackoverflow.com
My xDebug + Docker + PhpStorm config I use from project to project for years
Looks helpful, will give it a go! More on reddit.com
🌐 r/PHP
8
115
January 27, 2023
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 6599108484370-How-do-I-configure-xDebug-in-PHPStorm-in-using-Docker-containers
How do I configure xDebug in PHPStorm in using Docker containers? – IDEs Support (IntelliJ Platform) | JetBrains
July 13, 2022 - Bonus :) https://vimeo.com/433218463 ("In this video I teach myself how to run PHP's built-in web server to run a (very simple) Laravel application inside a Docker container, and then configure Xdebug and PhpStorm to do step debugging." Derick Rethans, Xdebug author)
🌐
JetBrains
jetbrains.com › help › phpstorm › configuring-xdebug.html
Configure Xdebug | PhpStorm Documentation
In this example, we're modifying /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini providing the mode and client_host Xdebug parameters. Note that the xdebug.client_host value should be replaced with the IP address of the machine where PhpStorm is running, which is accessible from the Docker container.
🌐
Docker Community
forums.docker.com › docker desktop
[solved] How to setup xdebug and phpstorm - Docker Desktop - Docker Community Forums
May 26, 2016 - Hello, I’m a bit confused using xdebug, docker for windows, and phpstorm… i have xdebug configured in a container with PHP. Here is what appears in my php.ini from within this container : xdebug.remote_enable=on xdebug.remote_autostart=off xdebug.idekey=PHPSTORM xdebug.remote_connect_back=1 xdebug.remote_host={{some IP address}} from this container i can’t access directly my Windows host IP, but i can access two IPs : the docker host IP which is 172.17.0.1 and the docker IP i have from Wi...
🌐
Medium
medium.com › ekino-france › xdebug-configuration-phpstorm-docker-desktop-817da3005556
Xdebug Configuration — PhpStorm / Docker | by Arthur Gorden | ekino-france | Medium
October 18, 2024 - The mapping corresponds to the container WORKDIR of your PHP Dockerfile. You can easily check it with: ... Map the root of the project and unfold the Project Files directory so you can map the project’s index.php (or the public directory if it is the entry-point of your application). ... Don’t forget to click on “Apply” when you’re done! Open PhpStorm’s settings. "Cmd" + "," on Mac "Ctrl" + "," on Linux and Windows · Then, unfold PHP and click on Debug. In the Xdebug part, keep the 9003 port (Xdebug’s port for version 3 and more).
🌐
Thecodingmachine
thecodingmachine.io › configuring-xdebug-phpstorm-docker
Debugging PHP (web and cli) with Xdebug using Docker and PHPStorm
July 26, 2018 - If you are starting a project, ... Note: the PHP_EXTENSION_XDEBUG environment variable is specific to the thecodingmachine/php. It automatically configures Xdebug for the container. Keep in mind that PHPStorm opens port 9000 (by default) so Xdebug can connect to it...
Find elsewhere
🌐
Keboola Tech Blog
500.keboola.com › xdebug-for-a-cli-app-in-docker-and-phpstorm
Xdebug for a CLI App in Docker (and PHPStorm)
September 16, 2022 - In Preferences > Languages & Frameworks > PHP, add a new CLI Interpreter. Choose the Docker option, and PHPStorm will automatically find the Xdebug image for you.
🌐
DEV Community
dev.to › pimenvibritania › debug-docker-php-project-on-phpstorm-using-xdebug-224f
Debug Docker PHP Project on PHPStorm using Xdebug - DEV Community
December 4, 2021 - EXECUTE! a. Set breakpoint, and ... earlier (PHP Remote Debug): c. Go to your endpoint, and add query string with parameter XDEBUG_SESSION_START and the value is your IDE Key, then execute!...
🌐
GitHub
gist.github.com › chadrien › c90927ec2d160ffea9c4
Debug PHP in Docker with PHPStorm and Xdebug · GitHub
FROM php:5.6.38-apache RUN apt-get update &&\ apt-get install --no-install-recommends --assume-yes --quiet ca-certificates curl git telnet iputils-ping net-tools &&\ rm -rf /var/lib/apt/lists/* RUN pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug \ && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" >> /usr/local/etc/php/php.ini \ && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/php.ini \ && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/php.ini \ && echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/php.ini \ && echo "xdebug.remote_host=docker.for.mac.localhost" >> /usr/local/etc/php/php.ini \ && echo "xdebug.idekey=IDEA_DEBUG" >> /usr/local/etc/php/php.ini \ && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/php.ini \ && echo "xdebug.remote_log=/tmp/xdebug.log" >> /usr/local/etc/php/php.ini
Top answer
1 of 2
6

Thanks to LazyOne's I took another look into the configuration and found out that the Step Debugger is disabled.

I install Xdebug in the following way in my php-fpm Dockerfile:

# Install xdebug
RUN pecl install xdebug && docker-php-ext-enable xdebug

And this is my original Xdebug configuration:

[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9001
xdebug.idekey=PHPSTORM
xdebug.remote_log=/var/www/storage/logs/xdebug.log
xdebug.remote_mode = req

I added

xdebug.mode = debug

After rerunning docker-compose up I started receiving a Notice in container logs:

rpg-app  | NOTICE: PHP message: Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(

I found this thread Xdebug: [Step Debug] Could not connect to debugging client

And added:

xdebug.client_host=host.docker.internal
xdebug.client_port=9001

Getting:

[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9001
xdebug.idekey=PHPSTORM
xdebug.remote_log=/var/www/storage/logs/xdebug.log
xdebug.remote_mode = req
xdebug.mode = debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9001

Now everything works! :)

Edit: Following LazyOne's comment I updated to Xdebug v3 configuration settings. The result is:

[xdebug]

xdebug.idekey=PHPSTORM

xdebug.mode = debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9001

xdebug.log=/var/www/storage/logs/xdebug.logs
2 of 2
2

From the looks of it you have set up everything correctly except perhaps the source path mapping (you find it under servers in PHPStorm). This is often the reason breakpoints are not working. Also try to enable the "Break at first line" option.

Unless you really need a docker compose for shipping I highly recommend using Lando. It always has the correct XDebug config and having real (https) URL's to work with helps a lot.

🌐
GitHub
gist.github.com › Raistlfiren › d4286169b7223054a6b23c169ee3f182
XDEBUG 3 Configuration with Docker and PhpStorm
Name docker-cli (Same as serverName under PHP_IDE_CONFIG environment variable) Host _ Default 80 · Debugger Xdebug · Check the checkbox next to "Use path mappings" Modify the absolute path on the server to /var/www/html · Add breakpoints file · In PhpStorm click the icon to "Start Listening for PHP Debug connections" Run in the docker file - docker-compose run php-container php test.php ·
🌐
Devilbox
devilbox.readthedocs.io › en › latest › intermediate › configure-php-xdebug › linux › phpstorm.html
3.2.1.2. Docker on Linux: Xdebug for PhpStorm — Devilbox 1.0 documentation
3.2.1.2. Docker on Linux: Xdebug for PhpStorm · Edit on GitHub · Attention · You can now run different PHP versions per project: Release v3.0.0-beta-0.1 · Docker on Linux allows Xdebug to automatically connect back to the host system without the need of an explicit IP address.
🌐
Benkyriakou
benkyriakou.com › posts › xdebug-docker-phpstorm
Setting up xdebug with Docker and PHPStorm | Ben Kyriakou
Check 'Filter debug connection by IDE key' and set the IDE key to match the one in your XDebug config (for the above we'd use PHPSTORM). Add a server (the name doesn't matter). Give it the appropriate host and port—for docker4drupal the host will be something like http://myproject.docker.drupal.localhost, and the port will be 8000 unless you've changed it.
🌐
GitHub
gist.github.com › manuelselbach › 8a214ae012964b1d49d9fb019f5f5d7b
xdebug docker on macOS with PhpStorm · GitHub
set port for xdebug Preferences -> Languages & Frameworks -> PHP -> Debug | Xdebug: Debug port = 9005 ... Happy debugging with docker!
🌐
Devilbox
devilbox.readthedocs.io › en › latest › intermediate › configure-php-xdebug › macos › phpstorm.html
3.2.2.2. Docker on MacOS: Xdebug for PhpStorm — Devilbox 1.0 documentation
No matter what this path is, the equivalent remote path (inside the Docker container) is always /shared/httpd. Important · Remember this, when it comes to path mapping in your IDE/editor configuration. 1. Ensure Xdebug port is set to 9000 · PHPStorm settings: Xdebug ·