0

Running a script.php from command line I do like this

$ php -f myscript.php

I can follow the process with die() and print_r(). But I can't connect with my IDE (IntelliJ) like a regular xdebug session comming from the Browser.

I am running inside a MacOS(HOST) connected with a docker ubuntu 16.04.

The IntelliJ is configured to listen incoming call from Docker. I think when I use my terminal I am using the php from my host and this is why the IntelliJ is not catching the connection.

Even when I run from the terminal inside the Docker container, the xdebug process in IntelliJ is not trigged.

Note: The xdebug is working good with the Docker and IntelliJ in a regular Browser session. I just pass the HOST IP when building the container and it works.

This is the portion of my Dockefile that set the xdebug:

RUN { \
        echo '[xdebug]'; \
        echo 'zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so'; \
        echo 'xdebug.remote_enable=1'; \
        echo 'xdebug.remote_port=9000'; \  
        echo 'xdebug.remote_autostart=1'; \
        echo 'xdebug.remote_handler=dbgp'; \
        echo 'xdebug.idekey=dockerdebug'; \
        echo 'xdebug.profiler_output_dir="/var/www/html"'; \
        echo 'xdebug.remote_connect_back=0'; \
        echo 'xdebug.remote_host=$REMOTE_HOST'; \
    } >> /usr/local/etc/php/php.ini

How could I achieve this debug process?

8
  • Duplicate of stackoverflow.com/questions/2288612/… Commented Apr 9, 2018 at 16:00
  • 2
    Possible duplicate of How to trigger XDebug profiler for a command line PHP script? Commented Apr 9, 2018 at 16:01
  • Hi, they are not using docker. I've tried those approaches and it is not working. Commented Apr 9, 2018 at 16:31
  • The point is that the only thing different with Docker is how you have configured networking. In order to connect to xdebug, you need to configure it. What port are you using? Did you make sure that port is mapped so that your IDE can connect to it? Commented Apr 9, 2018 at 18:15
  • My docker is working good with xdebug. It is already configured. Not only the port but also the host ip that should be sent to the container. The point is how to run the cli file to be caught by the IntelliJ in a cli session. I've tried to run from the terminal inside and outside container. But it is not working. Commented Apr 9, 2018 at 19:07

1 Answer 1

0

I have found a way to trigger the xdebug. Just called the myscript.php from the POSTMAN (GET or POST) will work. mysite.com/myscript.php

Sign up to request clarification or add additional context in comments.

Comments

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.