
Kernel tests run in a separate PHP process which means PHPStorm has a harder time dealing with them. In ddev you can use which is the internal connection string for the database, or for better performance use sqlite://localhost/sites/simpletest/db.sqlite We need to make sure the database configured in SIMPLETEST_DB is accessible to the remote PHP interpreter. Just make sure you have xdebug enabled ( ddev xdebug on). These should essentially “just work” as they run in a single process with no database, you don’t even need to be listening for connections. It's best to refer to the video above for these, but some brief info below. chrome:$DDEV_HOSTNAME Running and debugging tests Will be fixed in ddev soon.Ĭontainer_name: ddev-$ # DDev already sets this, add it here to debug Kernel tests.
Phpstorm debug full#
Add the following files then run ddev restart to regenerate the full docker-compose file. Fortunately we can extend the generated docker-compose file by adding extra files in the. There are a few extra parts we need for running every kind of test. For now you can revert ddev's docker-compose version with the following command:ĭdev config global -required-docker-compose-version=v1.29.2įor the most part DDev configures everything we need to use xdebug in PHPStorm. This defaults to v2 which still has some compatibility issues with PHPStorm.
Phpstorm debug update#
UPDATE JANUARY 2022 - Since v1.18.2 ddev now ships its own docker-compose version. Default config file - /var/www/html/phpunit.xml.PHPUnit library - Use Composer autoloader, set to absolute path in container, i.e.From the add dropdown choose PHPUnit by Remote Interpreter, then choose the one we set up already.CLI Interpreter: choose the interpreter we set up previously.Path to composer.json - absolute path on your local machine.You don’t need to map the web root or vendor dir since you’re mapping the entire project.home/michael/www/drupal -> /var/www/html Map the root of your project on your local machine to the absolute path on the docker container, e.g.Host: - must match the domain name of your drupal site.Uncheck Force break at first line when no path mapping specified - we’ll discuss this later when we start debugging Kernel tests.This setting allows us to listen on multiple ports. Note that xdebug 3 uses 9003 by default whereas xdebug 2 uses 9000. This should be set for you automatically. Lifecycle: Connect to existing container (‘docker compose -exec’).Add the environment variable COMPOSE_PROJECT_NAME=ddev-drupal (where drupal is the ddev project name in.Choose the full docker compose file generated by ddev found at.From the add dropdown choose From Docker, Vagrant, VM, WSL, Remote….Before we start let’s run ddev xdebug on to ensure the PHP extension is enabled. You can refer to the video above for an explanation of why some of these are needed.Īll of these settings are found under the PHP section of the PHPStorm settings dialog. In this section I’ll share the final configuration I’m using. You may be able to achieve the same result with an alternative docker-compose environment, but I'm using DDev here since it mostly works out of the box. You can also checkout the ddev-phpunit-demo repo if you want to try it out yourself with DDev and PHPUnit pre-configured. Drupal Test Traits / Selenium2DriverTests.
Phpstorm debug how to#
Click "Ignore" on that dialog, set up the server mapping, and try again, and you should get a proper debug session.Have a look at the video below that demonstrates how to configure everything you need to run and debug:


Then click "Listen for debug connections" in the toolbar, and run your script a dialog box should pop up showing the "Server name:" and "Server port:" it is trying to match, as well as confirming the remote file path. To find out what details you need to set up, go into "Settings > Languages and Frameworks > PHP > Debug", enable "Force break at the first line when no path mapping specified", and make sure "Ignore external connections through unregistered server configurations" is not ticked. For CLI scripts, the info to put in here will be based on your connection to the server where the CLI script runs. Normally, you would enter a URL into "Host" and set "Port" to the HTTP port, e.g. You need to set up a "server" configuration in "Settings > Languages and Frameworks > PHP > Servers" which maps the paths as seen on the server to the paths in your project.
