Skip to content
Advertisement

Docker toolbox Xdebug not working with PhpStorm

I tried all the tutorials I found on the internet and still can’t use a simple break point in PhpStorm using docker toolbox…

I currently have this inside my Dockerfile:

# Install xdebug
RUN pecl install xdebug; 
    docker-php-ext-enable xdebug; 
    echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "xdebug.remote_host=192.168.99.100" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "xdebug.idekey=PHPSTORM" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; 
    echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini;

Xdebug gets installed and configured correctly (php -i output):

xdebug.remote_autostart => On => On
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => 192.168.99.100 => 192.168.99.100
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9001 => 9001
xdebug.remote_timeout => 200 => 200
xdebug.idekey => PHPSTORM => PHPSTORM

In my PhpStorm configuration I have the following:

Proxy:

DBGp Proxy

Debug Debug

PHP interpreter PHP interpreter

Debug config Debug config

Server configuration Server config

The blurred items are Username and project name.

I have 2 folders in a project, one called docker and holds all the docker files and one site, that holds all the site files.

The configuration for my docker-compose is the following:

version: '3'

services:
  application:
    image: project_image:latest
    environment:
      - C_UID=${C_UID:-1000}
      - C_GID=${G_UID:-1000}
      - DEVELOPMENT=${DEVELOPMENT:-1}
      - ~/.ssh:/var/www/.ssh
      - ~/.composer:/var/www/.composer
    env_file:
      - .env
    volumes:
      - ${APPLICATION:-../site}:/phpapp
    ports:
      - 9001:9001

  nginx:
    image: dockerwest/nginx-laravel:${NGINXVERSION:-stable}
    environment:
      - VIRTUAL_HOST=${BASEHOST:-project_name.docker},${EXTRAHOSTS}
    volumes:
      - ${APPLICATION:-../site}:/phpapp
    links:
      - application
    ports:
      - 80:80

Anyone a clue on what I’m doing wrong here?

When I try to de telnet 192.168.99.100 9001, the connection can’t be made, port 9000, neither, but port 80 gives me a good response.

Anyone who has an idea what’s going on here?

Advertisement

Answer

Xdebug needs to open a connection to PhpStorm. You don’t need the ports exposed in Docker, or do anything with the Xdebug proxy. The telnet needs to be done from within your docker container to PhpStorm. The IP address in xdebug.remote_host, needs to be the IP address of your IDE, and not the IP address of your docker container (where HTTP/Apache listens on port 80).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement