proophessor-do: Unable to instantiate xdebug

Hello,

I have hard time to instantiate xdebug for proophessor-do.

I have cloned the project and added it to Phpstorm projects in order to be able to put some break-points and see exactly the route it takes for each functionality in order to better understand prooph components.

for docker-compose.yml I changed the php section into this:

  php:
    image: prooph/php:7.1-fpm-xdebug
    volumes:
      - .:/var/www
    depends_on:
      - mysql
      - mongodb
    environment:
      - PROOPH_ENV=development
      - XDEBUG_CONFIG="remote_host=192.168.1.9"
      - PHP_IDE_CONFIG="serverName=Prooph-docker"

everything else is default

For the phpstorm part:

DBGp Proxy settings: enter image description here

Server settings: enter image description here

Run/Debug Configurations (docker) enter image description here

Run/Debug Configurations (PHP Remote Debug) enter image description here I have tried also with checked Filter… checkbox

my ifconfig result:

 ~ $ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
XHC0: flags=0<> mtu 0
EHC250: flags=0<> mtu 0
EHC253: flags=0<> mtu 0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=b<RXCSUM,TXCSUM,VLAN_HWTAGGING>
	ether c4:2c:03:24:83:a0
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (none)
	status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 60:33:4b:0b:61:83
	inet6 fe80::cc9:38d4:7cf:1b54%en1 prefixlen 64 secured scopeid 0x8
	inet 192.168.1.9 netmask 0xffffff00 broadcast 192.168.1.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
	ether 02:33:4b:0b:61:83
	media: autoselect
	status: inactive
fw0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 4078
	lladdr e8:06:88:ff:fe:f0:eb:0e
	media: autoselect <full-duplex>
	status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	inet6 fe80::249a:d86c:ab3e:6e1a%utun0 prefixlen 64 scopeid 0xb
	nd6 options=201<PERFORMNUD,DAD>

When I run Docker from PhpStorm: enter image description here

When I run the debugger from PhpStorm: enter image description here

And still, breakpoints are getting ignored…

I probably miss something on the way, but I’m not sure what is it.

This is my phpinfo() for the xdebug section: enter image description here

And this is the Environment section from phpinfo() enter image description here

I saw here that the IDE Key is set on www-data, and I set www-data as the IDE key to listen for in PhpStorm, but still nothing happened… enter image description here

Also, it is my first time using docker, I never used it before. I used to use virtual box for mac, and my remote debug worked fine, so I guess the steps to follow with docker are more or less the same… no?

As @codeliner suggested I’m pinging @sandrokeil on this.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Hi,

For me it was hard to set it up too, because of the configuration of the remote connection. I use php:7.1-fpm, but I suppose it will be similar for you.

This is my configuration:

.env file:

# Host Local IP (for Xdebug)
HOST_IP=docker.for.mac.localhost

# Server name (for Xdebug in CLI)
PHPSTORM_SERVER_NAME=www.project.localhost

The relevant part of my docker-compose.yml file, the one that refers to the PHP container:

    php:
        container_name: project-php
        build:
            context: docker/php7-fpm
            args:
                HOST_IP: ${HOST_IP}
                PHPSTORM_SERVER_NAME: ${PHPSTORM_SERVER_NAME}
        volumes:
            - ./docker/logs/symfony:/var/www/${SYMFONY_APP_NAME}/var/logs:cached
            - ${SYMFONY_APP_PATH}/vendor:/var/www/${SYMFONY_APP_NAME}/vendor:cached
            - ${SYMFONY_APP_PATH}:/var/www/${SYMFONY_APP_NAME}

And the relevant part of my Dockerfile:

FROM php:7.1-fpm

ARG PHPSTORM_SERVER_NAME
ARG HOST_IP

...

# install xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN printf "xdebug.remote_host=%s" ${HOST_IP} >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN printf '\nexport PHP_IDE_CONFIG="serverName=%s"\n' ${PHPSTORM_SERVER_NAME} >> ~/.bashrc

Then, my xdebug configuration in PHPStorm is as follows:

The configuration for xdebug:

image

And the configuration for server —it is a Symfony 3.4 application, it may differ for you—:

servers

Hope it helps!

Regards!

@rubenrubiob Thank you for the comment!

I was about to try that today, as I said to @codeliner in Gitter yesterday, building xdebug from pecl should do the trick and you prove me correct as it works now!

@codeliner in regards to issue #161 maybe instead of cloning xdebug source and compile it, just to install pecl extension? Because other than that I don’t see any difference that could cause the issue 😦

Thanks again @rubenrubiob for taking the time to help!

I didn’t changed anything from my previous settings, all I did was changing my docker-compose.yml and add Dockerfile and then run $ docker-compose up -d and xdebug now works fine!

./docker-compose.yml file (only php section):

  php:
    image: prooph/php:7.1-fpm
    build:
      context: .
      dockerfile: Dockerfile
    restart: always
    volumes:
      - ./etc/xdebug.log:/tmp/xdebug.log
      - "./etc/xdebug-custom.ini:/usr/local/etc/php/conf.d/xdebug-custom.ini"
      - .:/var/www
    depends_on:
      - mysql
      - mongodb
    environment:
      PROOPH_ENV: "development"
      XDEBUG_CONFIG: "remote_connect_back=0"
      PHP_IDE_CONFIG: "serverName=prooph-docker"
      PHP_XDEBUG_ENABLED: 1

./Dockerfile:

FROM php:7.1-fpm

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

et voilà! xdebug now works! 😃

@sandrokeil, without knowing the exact reason behind that but yes, pecl install xdebug solve this issue for me. Also, that happened to me in the past as well, when I was in the mood that everything needs to be compiled from source in order to work best with your OS, and xdebug never worked for me. And by saying past I go back in Mac OS X Leopard edition, I stopped trying to find the solution since Mavericks, but pecl always was working for some reason.

Also, I had clean install almost every-time after new OS version and I had a new Macbook Pro machine somewhere down the road, thus I don’t think that it is something related to my setup.

Would be cool to know why compiling xdebug from source is not working, but even if I won’t find out about it I can live with it haha

@rubenrubiob yeah indeed it is! Hope this topic will help others as well! Lot’s of information here for Docker+Mac users 😄