Reputation: 1587
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:
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?
Upvotes: 2
Views: 1604
Reputation: 3358
It is also worth emphasizing that is it either xdebug.remote_host OR xdebug.remote_autostart. This is mentioned both in the docs and the previous comment.
In other words - If you are having the feeling that your remote_host setting is being ignored, check if remote_autostart is not accidentally turned on.
Upvotes: 0
Reputation: 1711
3 conditions must be fulfilled for xdebug to work remotely with VirtualBox, I had it especially in connection with Docker inside virtualbox.
1) remote_connect_back=1 or the exact ip address of your host machine (which can differ often) must be listed in the remote_host config field (, sometimes both at the same time don't work together, especially in the case of a docker being separately from a virtualbox = at windows hyper-v directly)
2) no other application like eg. a web-project can be exposed at the port 9000, that must be reserved for the php editor, or a different port must be reserved by the editor/listened at (or for the php web project), and addressed/transmitted to from the php, it is a project-based configuration
3) it's similar to the second point, VirtualBox must have no port forwarding to that port, as it would effectively occupy it but it must be reserved for the php editor, not for virtualbox port forwarding. Not virtualbox has to listen at that port to be forwarded to some internal app, but the outer php-editor has to listen for it=that port
Upvotes: 1
Reputation: 36784
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).
Upvotes: 2