question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to instantiate xdebug

See original GitHub issue

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!

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
rubenrubiobcommented, Mar 26, 2018

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!

2reactions
panosrucommented, Mar 26, 2018

@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! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Unable to start Xdebug debugging session" in ...
I am trying to use Xdebug in Sublime Text 3 in Fedora 31, but when I start debugging I get this error: Unable...
Read more >
Documentation » Installation - Xdebug
Sometimes there is a mismatch with the default and PECL will fail, or Xdebug won't load with ... Create a PHP page that...
Read more >
Configure Xdebug | PhpStorm Documentation - JetBrains
To enable Xdebug, locate or create the [xdebug] section in the php.ini file and update it as follows: Xdebug 3. Xdebug 2.
Read more >
Can't start xdebug - Server Fault
For some reason, I had to erase my ZendStudio "workspaces" folder, and import all my projects again, and of course, changed por of...
Read more >
How to Use Xdebug for Advanced PHP Debugging
254.254' to create what i believe is a static IP, but can not get it running on the other project. Any insight would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found