3

I'm trying to setup Xdebug to help our development cycle but I'm having some difficulty getting it working. I've also never used Xdebug before so maybe I'm misunderstanding how it works.

We're using PHP7 running on Docker containers with nginx in front of it. These Docker containers are hosted on a private VPC on EC2 servers.

I've installed xdebug-2.5.4 through my dockerfile

RUN wget http://xdebug.org/files/xdebug-2.5.4.tgz && tar -xvzf xdebug-
2.5.4.tgz
WORKDIR xdebug-2.5.4
RUN phpize
RUN ./configure
RUN make && cp modules/xdebug.so /usr/lib64/php/modules

I've confirmed that it's installed by checking my installed php modules (php -m)

I've modified my PHP.ini:

[xdebug]
zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_host="<ip address of machine running docker>"
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.remote_log="/tmp/xdebug.log"

I've modified my PhpStorm preferences with the host as the same IP address and port in xdebug.remote_host and xdebug.remote_port.

However, I'm at a loss as to where to continue from here. It's worth noting that this isn't running a PHP Web Server, but more of a RESTFUL API that we test using Postman. Is it even possible to use xdebug with such a workflow?

26
  • 1) "I've modified my PHPStorm preferences with the host as the same ip address and port in xdebug.remote_host and xdebug.remote_port" Please clarify this part .. especially PhpStorm side... because you so not have to configure any IP here in PhpStorm .. only in xdebug settings. 2) "xdebug.remote_enable=on" and "xdebug.remote_enable=1" -- no need to repeat it twice. Commented Sep 24, 2017 at 22:14
  • I added the host and port for the DBGp Proxy setting in PHPStorm. And yes, you're right I didn't see the repetition there! I'll remove that Commented Sep 24, 2017 at 22:19
  • 3) "It's worth noting that this isn't running a PHP Web Server, but more of a RESTFUL API that we test using Postman." But you are executing PHP code to serve those API requests, right? from debugging POV it does not matter what your code returns -- proper/full HTML page or JSON data. Commented Sep 24, 2017 at 22:19
  • 1
    Just in case (if it's got lost in this many-comments content) -- 1) it's xdebug that connects to IDE and not other way around. So xdebug must be able to reach your computer (firewall on AWS must allow outgoing connection on TCP 9000 port; and your local firewall/router must allow incoming connection) 2) It must be an IP of PC where IDE is running. 3) If it will be "direct" connection (from AWS to your PC) then few possible issues: 3.1) Your IP might be changing often so you may need to configure that again 3.2.) You may simply not have a "white" IP or your ISP might be blocking such incoming Commented Sep 24, 2017 at 22:46
  • 1
    4) therefore it's better to use SSH tunnel -- you establish secure connection to your VPC .. and then xdebug connects to that "local" IP inside PVC and SSH will forward it to your local PC -- will solve #3. You may use DBGp Proxy for this.. but it's not really needed (unless you will have more than 1 dev debugging at a time). In any case -- always check what xdebug log has to say -- it will tell what IP:port it tries to connect to and if connection was successful or not. Commented Sep 24, 2017 at 22:48

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.