markshust / docker-magento

Mark Shust's Docker Configuration for Magento
https://m.academy/courses/set-up-magento-2-development-environment-docker/
MIT License
2.57k stars 1.01k forks source link

Debugger is not triggering on breakpoints after setting up #350

Closed gosteev closed 3 years ago

gosteev commented 3 years ago

Hello! First of all, I want to thank you for this great docker configuration. I find it very handy and switched most of the projects I'm working on to it. However, I can't set up my debugger using this instruction: https://github.com/markshust/docker-magento#xdebug--phpstorm

Description Can't set up my debugger

Steps To Reproduce Go through the steps of this instruction https://github.com/markshust/docker-magento#xdebug--phpstorm

Expected Result PHPStorm will stop on the breakpoints

Actual Result PHPStorm is not stopping, I can see waiting for incoming connections with ide key 'PHPSHORM' text

===

bin/cli php -v output:

PHP 7.4.8 (cli) (built: Jul 22 2020 09:39:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.1, Copyright (c) 2002-2020, by ionCube Ltd.
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans
    with blackfire v1.36.0~linux-x64-non_zts74, https://blackfire.io, by Blackfire

PHP config: image

PHP server: image

Debug configuration: image

Xdebug helper extension options: image

Debug and DBGp Proxy ports are set to 9001 inside PHPStorm settings

r-martins commented 3 years ago

Try adding PHP_IDE_CONFIG: "serverName=ShustDocker" in docker-compose.dev.yml.

image
niziou commented 3 years ago

It's xdebug is not working out of the box, the above solution did not help it either. I am using php72-fpm2 if it matters.

r-martins commented 3 years ago

Double check your PhpStorm settings..

  1. The port must be the same configured in php.ini

    image image
  2. Check the server address

    image

    as per the image in my previous message

  3. Remember to enable xdebug bin/xdebug enable and check if it's enabled with bin/cli php -v

    image
niziou commented 3 years ago

After adding this php ide config and chaning server name the xdebug started. Thanks for help. However this should work out of the box + steps from github or documentation should be updated.

vy-shmal commented 3 years ago

I have the same problem, cant make xdebug work.

OS I have Ubuntu 20.04.1 LTS

I am trying to configure phpstorm for the remote PHP Remote Debug. I followed the configuration on the documentation, with no success, I also made the configuration from above but still nothing.

Here is my config.

Screenshot from 2020-12-18 11-20-13

Screenshot from 2020-12-18 11-20-28

Screenshot from 2020-12-18 11-21-16

Screenshot from 2020-12-18 11-21-29

Screenshot from 2020-12-18 11-23-04

Screenshot from 2020-12-18 11-24-52

Screenshot from 2020-12-18 11-27-18

r-martins commented 3 years ago

What about your .yml file? And your php.ini config?

ssstankiewicz commented 3 years ago

@vy-shmal On Linux don't forget about uncomment these two lines in docker-compose.dev.yml docker

vy-shmal commented 3 years ago

Yes that was it! Thank you a lot @ssstankiewicz .

vy-shmal commented 3 years ago

What about your .yml file? And your php.ini config?

Sorry @r-martins for the delay of the response, now I found time to reply.

php.ini is the default of the docker with xdebug enabled. the .yml was the default of docker

Here is the docker-compose.dev.yml with the solution above:

# (https://github.com/markshust/docker-magento)
#
# Version 34.2.0

version: "3"

services:
  app:
    volumes: &appvolumes
      # Host mounts with performance penalty, only put what is necessary here
      - ./src/app/code:/var/www/html/app/code:cached
      - ./src/app/design:/var/www/html/app/design:cached
      - ./src/app/etc:/var/www/html/app/etc:cached
      - ./src/composer.json:/var/www/html/composer.json:cached
      - ./src/composer.lock:/var/www/html/composer.lock:cached
      - ./src/nginx.conf.sample:/var/www/html/nginx.conf:cached
      #- ./src/auth.json:/var/www/html/auth.json:cached
      #- ./src/m2-hotfixes:/var/www/html/m2-hotfixes:cached
      #- ./src/patches:/var/www/html/patches:cached
      #- ./src/var/log:/var/www/html/var/log:cached
      #- ./src/var/report:/var/www/html/var/report:cached
      # To sync your SSH to the container, uncomment the following line:
      #- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
      # Linux only: remove the above lines and mount the entire src directory with:
      - ./src:/var/www/html:cached

  phpfpm:
    volumes: *appvolumes
    environment:
      PHP_IDE_CONFIG: "serverName=ShustDocker"
    # Linux only: host.docker.internal doesn't exist https://github.com/docker/for-linux/issues/264
    # Uncomment two lines below & replace IP with result of: docker run --rm alpine ip route | awk 'NR==1 {print $3}'
    extra_hosts:
      - "host.docker.internal:172.17.0.1"

  mailhog:
    image: mailhog/mailhog
    ports:
      - "1025"
      - "8025:8025"

  # Disabling cron by default as it uses higher CPU, enable if needed
  #cron:
  #  volumes: *appvolumes

Thank you for your time.

markshust commented 3 years ago

It appears this issue is resolved.

I initially created this repo for Mac, but since then 5 years has passed, and it has become popular on Linux as well. I'll try to improve the setup process for Linux users so more of this is automated. It could potentially also help out users on Windows WSL.

Closing this as it appears to be resolved/non-issue.

gosteev commented 3 years ago

an issue is not resolved. I tried adding PHP_IDE_CONFIG and extra_hosts to docker-compose file, triple-checked all the settings, still no luck :(

docker run --rm alpine ip route | awk 'NR==1 {print $3}' prints 172.17.0.1

image

markshust commented 3 years ago

Reopening this issue for visibility.

Is anyone else having problems running Xdebug on Linux?

These lines within the docker-compose.yml file should do the trick:

...
  phpfpm:
    volumes: *appvolumes
    environment:
      PHP_IDE_CONFIG: "serverName=ShustDocker"
    # Linux only: host.docker.internal doesn't exist https://github.com/docker/for-linux/issues/264
    # Uncomment two lines below & replace IP with result of: docker run --rm alpine ip route | awk 'NR==1 {print $3}'
    extra_hosts:
      - "host.docker.internal:172.17.0.1"
      ...

Other than that, I'm not sure what else it could be. No other changes should be needed, so if you made any other changes I'd recommend backing them out.

pykettk commented 3 years ago

Is anyone else having problems running Xdebug on Linux?

Yeah, still a problem for me on Ubuntu 20.04.1 and Docker version 20.10.2, build 2291f61.

The suggested changes above do not resolve this issue for me either. PhpStorm sits in a constant state of waiting for incoming connections.

markshust commented 3 years ago

This should be resolved on the latest images.

niners52 commented 2 years ago

Is anyone else having problems running Xdebug on Linux?

Yeah, still a problem for me on Ubuntu 20.04.1 and Docker version 20.10.2, build 2291f61.

The suggested changes above do not resolve this issue for me either. PhpStorm sits in a constant state of waiting for incoming connections.

@pykettk Did you ever get this resolved?

markshust commented 2 years ago

@pykettk I think @niners52 & I resolved this issue. I'll be pushing out an update momentarily, but it has to do with extra_hosts and a DNS entry not setup for host.docker.internal.

markshust commented 2 years ago

This should be fully resolved in 41.0.2 https://github.com/markshust/docker-magento/blob/master/CHANGELOG.md#4102---2021-12-09

There is a new PHP image that should also expose port 9003, which may resolve some issues.