Home » Php » How to debug remote nanobox php container?

How to debug remote nanobox php container?

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have a PHP container running with nanobox and I have no problem working with xdebug when running the container on my local machine, but I can’t get to make it work on the remote container as well.

Xdebug is up and running on the remote container, this is what I checked:

/app $ php -i | grep xdeb
/data/etc/php.d/xdebug.ini
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
....

And this is my configuration(I’m using VSCode):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/app": "${workspaceRoot}/",
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

I did try to forward port 9000 as well, like this:

nanobox tunnel staging web.main -p 9000:9000

But it didn’t work.

How to&Answers: