0

My PHP application runs in docker. My IDE is PhpStorm. I configured like this:

PhpStorm configuration

My Docker configuration contains:

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini

and docker-compose.yml contains like:

environment:
  -XDEBUG_CONFIG: "remote_host=192.168.0.111 idekey=phpstorm"
  -PHP_XDEBUG_ENABLED: 1 # Set 1 to enable.

And I run my docker as;

docker-compose up.

When I access a page, it is not hitting my breakpoints.

What setting I miss here?

Debug setting in PhpStorm:

enter image description here

2
  • is phpstorm listening ? what do the xdebug log file say ? can you telnet 192.168.0.111 port 9000 and get session going ? If you click on Debug (right above DBGp proxy) what are the settings for Xdebug ? Commented Aug 10, 2017 at 1:39
  • @YvesLeBorg Im really new to php. SInce i had issue setting my php storm, I use docker for my development too. telnet gives, Trying 192.168.0.111... Connected to dc1v8x1.lob.local. I provided debug screenshot too in my original question Commented Aug 10, 2017 at 1:47

1 Answer 1

0

It's really hard to get this working. The short answer is that Docker is not for debugging. Use Vagrant.

Docker is meant to run tiny applications called containers. You want to run the smallest possible process like a database, and then run your http server in another container. Because of this, the standard containers are all bare bones. They're not meant to solve complicated issues. Docker is for production.

Vagrant, on the other hand, is well-suited to developers. It has a lot of niceties that support the developer and make life easier. It works on Mac, Windows, and Linux, and it runs the same way on all of them so you can easily use this in a team setting by sharing just the Vagrantfile, you get "cloning". It even mounts local folders, and thus gives you real-time updates with your http server. You can also destroy the Vagrant image over and over again which is really nice. A good tip is to record all your setup steps in the Vagrantfile. When you have a good Vagrant setup, destroy the Vagrant image, recreate it, and never touch what's inside of it again. This also really helps when you put a project aside for 6 months and can't remember what you did 6 months ago.

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

3 Comments

Thank you. But I have my environment issue(MAC+PHP+MSSQL) That is why I use, docker. SO you say, It is really hard to debug the code?
@Ratha "SO you say, It is really hard to debug the code? " Debugging will work -- just have a look at questions in "Related" section on this page (or search for "phpstorm xdebug docker" tags). P.S. You seems to be new to PHP/xdebug as you are trying to use DBGp Proxy (which you extremely likely do not have there) -- typical thing new users are trying to do is to fill every field without even knowing what this for and how it works.
Agreed. It will work. You will have a fun time getting it working and maintaining it, though. Whereas with Vagrant, it's designed specifically with developers in mind. In fact, there are serious issues with the Community Edition that prevent it from working properly on many different user OS/software combinations. In fact, our team had two critical issues on two different co-workers systems.

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.