user424370
user424370

Reputation: 109

How to set up xdebug / docker / drupal stack?

My objective is to be able to debug a tricky piece of Drupal 8 code. My experience with docker is very limited (beginner level). I have a database docker container running which I spinned like this:

docker run --name drupalMulti-database -p 3306:3306 -v `pwd`:/var/lib/mysql -d percona:latest

Then, my drupal 8 docker container is connected to the container above like this:

docker run -e XDEBUG_CONFIG="remote_host=10.1.2.74" --name drupalMulti -p 8484:80 -p 8453:443 --link drupalMulti-database:mysql -v `pwd`:/var/www/html/ -d gitlab.OUR-COMPANY-NAME.com:4999/dev/PATH-TO-OUR-DRUPAL-CONTAINER

I am wondering how can I configure either PhpStorm or VsCode to work properly with xdebug, so I could debug my drupal code: set breakpoints, step into the code etc? Assume that I have no access to modify the existing docker images, but my Drupal image already has xdebug pre-installed.

(Running Drupal 8 / php 7.2 / mysql 5.7)

Upvotes: 0

Views: 1356

Answers (1)

Dmitrii
Dmitrii

Reputation: 3557

Try setting xdebug.remote_host to host.docker.internal if the docker is running locally. You also would need to have a copy of the project stored locally to be able to debug it via PhpStorm. See https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html#configuring-xdebug-docker and https://www.jetbrains.com/phpstorm/documentation/debugging/

Upvotes: 1

Related Questions