docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

Xdebug not working

Open niketkanoi opened this issue 5 years ago • 6 comments

I followed Mark's video to configure Xdebug. When I load the pages, not getting any breakpoints configured. Can someone help? I can provide what my configs are based on what you may need to troubleshoot.

niketkanoi avatar Jul 01 '21 14:07 niketkanoi

I had to change the port to 9300 (for xdebug 3) then it worked.

kamephis avatar Jul 08 '21 11:07 kamephis

I had to change the port to 9300 (for xdebug 3) then it worked.

This port 9300 is the port for elasticsearch. Could you check which port you changed. I have debug issue as well.

munkhulzii avatar Aug 31 '21 09:08 munkhulzii

This article goes into detail on a fix: https://matthewsetter.com/setup-step-debugging-php-xdebug3-docker/

In short, run bin/bash to get into the php-fpm container. Then go to /usr/local/etc/php/conf.d and edit the docker-php-ext-xdebug.ini file to match this:

zend_extension=xdebug

[xdebug]
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes

Save that file, then exit out of the bash terminal to your host machine. Run bin/restart to restart the containers. That should get you going.

joshuabromero avatar Sep 01 '21 02:09 joshuabromero

I had to change the port to 9300 (for xdebug 3) then it worked. Try to change the port to 9003 in PhpStorm Xdebug config section => Preferences | Languages & Frameworks | PHP | Debug (old value was 9001)

iAlexanderS avatar Sep 02 '21 18:09 iAlexanderS

You shouldn't need to change any config settings within the container or ini file to get Xdebug working. The culprit here was most likely this last comment, where PhpStorm was listening on the wrong port.

markshust avatar Sep 07 '21 13:09 markshust

@markshust That is wrong. On linux it definitely doesn't work out of the box. bin/xdebug status shows enabled.

I did this:

  1. Add - ./src/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini to the
services:
  app:
    volumes: &appvolumes

section of docker-compose.dev.yml

  1. Create a ./src/docker-php-ext-xdebug.ini with

[xdebug]
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
  1. bin/restart
  2. Throw a breakpoint into your IDE and it should work now.

EmperorKonstantin avatar Sep 15 '21 23:09 EmperorKonstantin