php - Docker Compose and Xdebug not working in PhpStorm

379

I've tried many things trying to let work Xdebug in a Docker container. I came in contact with these resources:

I think the problem is either something with the ports that I don't understand, or it is something with the debugger session not being started or recognized. For the debugger session I have also tried to install a browser extension that sets a cookie.

I ended up at least to have separate containers, one as dev container with enabled Xdebug.

docker-compose.yml

version: "3"
services:
  production:
    build: .
    ports:
      - "8000:80"
    volumes:
      - .:/var/www/html
  development:
    build: .
    ports:
      - "8080:80"
#      - "10000:80" also not working
    volumes:
      - .:/var/www/html
      - ./dev.php.ini:/usr/local/etc/php/php.ini

Dockerfile

FROM php:7.4.0-apache

RUN pecl install xdebug \
  && docker-php-ext-enable xdebug

dev.php.ini

xdebug.remote_enable=on
xdebug.remote_host=host.docker.internal
xdebug.remote_port=10000
xdebug.idekey=PHPSTORM

localhost:8080 phpinfo data

enter image description here

enter image description here

PhpStorm config

enter image description here

Any ideas?

People are also looking for solutions to the problem: php - Uber Uploader XML ERROR: XML_ERR_NAME_REQUIRED at line 1 with hwdMediaShare

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.