You are trying to pass it as Xdebug IDEKey param. dxdebug.idekey="serverName=myapp.localhost" It's a per-project setting so you can use old 9000 port in another project if needed. But it uses the first in a list for CLI scripts (which PHPUnit is).Įither remove it (preferred so you will only have 9003 there) or make it last (i.e. In PhpStorm you most likely have both old and new ports listed ( 9000,9003 as a default value) to cover new and old Xdebug versions. Xdebug 3 now uses 9003 port by default instead of 9000. Request for helpĪny idea about how to configure PhpStorm to start an Xdebug session to debug a PHPUnit test? I imagined that an error should have occurred, but different, something saying a required parameter is missed. Nevertheless, PhpStorm continues to pop up the same error mentioning xdebug.remote_host=. *)?$/" -test-suffix ProfileTest.php /opt/project/tests -teamcityĪs you can see, there is no mention of xdebug.client_host nor of xdebug.remote_host. Now, the resulting command is this: :php /opt/project/vendor/phpunit/phpunit/phpunit -configuration /opt/project/phpunit.xml -filter "/(ProfileTest::testProfileUpdate)(. Then, in the section "Advanced settings" I unflagged the option "Pass required configuration options through command line". I tried to disable params passed automatically by PhpStorm going to Settings > PHP > Debug. Tried to disable params passed by PhpStorm *)?$/" -test-suffix ProfileTest.php /opt/project/tests -teamcityĪlso with this configuration, Xdebug doesn't start and breakpoints are ignored (and the error message pops up). The resulting command is this: :php -dxdebug.mode=debug -dxdebug.client_port=9000 -dxdebug.client_host= -dxdebug.idekey="serverName=myapp.localhost" ssion=1 /opt/project/vendor/phpunit/phpunit/phpunit -configuration /opt/project/phpunit.xml -filter "/(ProfileTest::testProfileUpdate)(. -dxdebug.idekey="serverName=myapp.localhost".I've also tried to configure two more flags: *)?$/" -test-suffix ProfileTest.php /opt/project/tests -teamcity Looking at the command executed by PhpStorm to debug a test method, here is what I see: :php -dxdebug.mode=debug -dxdebug.client_port=9000 -dxdebug.client_host= /opt/project/vendor/phpunit/phpunit/phpunit -configuration /opt/project/phpunit.xml -filter "/(ProfileTest::testProfileUpdate)(. Probably 'xdebug.remote_host=' is incorrect. If I debug the test clicking on the "bug" icon on the left of the test method, instead, I receive the following error:Ĭonnection was not established. In fact, if I run tests from command line, Xdebug stops at breakpoints: XDEBUG_SESSION=1 PHP_IDE_CONFIG="serverName=myapp.localhost" vendor/bin/phpunit -testdox -filter testProfileUpdate Xdebug is correctly setup and also the server in PhpStorm is. Once you do so, you can just start the container and execute the script, and then you will see the client that was waiting connecting and getting into interactive mode.I'm trying to use Xdebug (v3) through PhpStorm (v2022.3.2) to debug a PHPUnit test method from inside a Docker container. docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini You will get a json structure and there you need to pick the ip from IMAP > Config > Gateway.ĭon't forget to setup the configuration files ont he volumes section of the docker-compose.yml file so it gets copied to the container. Now here it comes the tricky part, the client_host ip changes and you need to figure out which one is yours, in order to do so you need to inspect the docker network your container is running in using docker network ls and docker network inspect with the network identifier. docker/php/conf.d/xdebug.ini and put there the following configuration parameters. That would install it when building the container, and for configuring it we need to copy the configuration into the container, so I will create the following configuration file into a folder in my project like. To install Xdebug the following lines need to be added to the Dockerfile. The next thing is going to be installing and configuring Xdebug inside the docker container, and make it connect the host machine in that port. Waiting for debug server to connect on port 9003 Now the debugging client will be waiting for connections on our host machine, the following message will be prompted: There are thousands of articles for setting up debugging on a complex IDE like PHPStorm, but if you like minimal configurations like me, you can just download and run the minimal DBGp client from the official Xdebug website.Ī simple way of doing this would be: wget This brief post will be more like a note for my future self, to know how to setup Xdebug for debugging complex problems on PHP code that is running inside a Docker container.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |