Docker Community Forums

Share and learn in the Docker community.

PHP xDebug works from browser but not from CLI


(Geoffrey Hoffman) #1

I’ve grown to absolutely love Docker and have several webapp containers, a DB container, ElasticSearch, etc. Everything works beautifully, including xdebug. I have a single php.ini on the container, and use a different xdebug port for each app/container. A few are Apache+mod_php, a few are Nginx+PHP-FPM - it doesn’t matter, it works fine so long as I use the browser to run the project and it appends the ?XDEBUG_SESSION_START=netbeans to the URL.

The only thing I cannot seem to figure out is - no matter what I try, I cannot make xdebug work on the command line, to debug php console commands. These files are in the same project in the same folder as my working web project, so I don’t think file mapping is the problem. I thought I might need to expose the xdebug port (eg 9000) in the docker run command, but that didn’t have any effect. Even if I start the debugger, make the connection via the browser, and then run a cli command, it never stops on debug points.

Has anyone else run into this?