2

Trying to debug PHP from IntelliJ on Windows 10.

These are the first lines in my Dockerfile:

FROM drupaldocker/php:7.1-apache

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

I tried copying and pasting configuration from several sources, e.g.:

&& echo "error_reporting = E_ALL" > /usr/local/etc/php/php.ini \
&& echo "display_startup_errors = On" >> /usr/local/etc/php/php.ini \
&& echo "display_errors = On" >> /usr/local/etc/php/php.ini \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.idekey=\"PHPSTORM\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

The result is always the same.

I start the container via docker-compose and map port 9000 to localhost:9000 using the following line in compose yml.

ports:
    - "9000:9000"

When I try to start listening from IntelliJ I get the error: Port 9000 is busy.

I tried telnet 127.0.0.1 9000 I get the message: connection closed by foreign host.

Any idea what could be wrong?

7
  • See if this helps tarunlalwani.com/post/debugging-php-xdebug-docker Commented Sep 24, 2017 at 4:53
  • 1
    1) "I start the container and map port 9000 to localhost:9000" WHY? It's xdebug that connect to IDE and not other way around ... so why opening it in Docker? (please read the xdebug basics) 2) Why do you have 2 different occurrences of xdebug.remote_connect_back rule? 3) BTW -- remote_connect_back most likely will not work and you will need to specify the remote_host manually (the IP where IntelliJ is running). 4) stackoverflow.com/q/44032296/783119 .. or the link that TarunLalwani provided Commented Sep 24, 2017 at 10:59
  • >> "I start the container and map port 9000 to localhost:9000" please describe how you map the ports (I think the problem is somewhere here) Commented Sep 24, 2017 at 11:01
  • You need to connect form inside of a Docker (from xDebug) to localhost:9000 (to server upped by IntelliJ): stackoverflow.com/questions/24319662/… . Also see links in comments above. Commented Sep 24, 2017 at 11:10
  • edited to add the lines of compose yml that I've used to map ports Commented Sep 24, 2017 at 11:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.