Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xdebug: don't work #1193

Closed
vudev opened this issue Oct 16, 2017 · 20 comments
Closed

Xdebug: don't work #1193

vudev opened this issue Oct 16, 2017 · 20 comments
Labels

Comments

@vudev
Copy link

vudev commented Oct 16, 2017

Info:

  • Docker version ($ docker --version): Docker version 17.09.0-ce, build afdb6d4
  • Laradock commit ($ git rev-parse HEAD): 903c774
  • System info (Mac, PC, Linux): Mac Os high sierra, laradock, phpstorm, xdebug helper
  • System info disto/version: Mac Os high sierra

Issue:

Xdebug don't work.
In phpstorm show:
Waiting for incoming connection with ide key 'PHPSTORM'

in docker-composer.yml
workspace:
build:
context: ./workspace
args:
- INSTALL_XDEBUG=true
php-fpm:
build:
context: ./php-fpm
args:
- INSTALL_XDEBUG=true

xdebug.ini
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.remote_port=9000
xdebug.remote_host=dockerhost
xdebug.idekey=PHPSTORM

screen shot 2017-10-16 at 4 37 36 pm
screen shot 2017-10-16 at 4 38 07 pm
screen shot 2017-10-16 at 4 40 00 pm
screen shot 2017-10-16 at 4 40 20 pm
screen shot 2017-10-16 at 4 40 29 pm
screen shot 2017-10-16 at 4 39 27 pm
screen shot 2017-10-16 at 4 39 38 pm
screen shot 2017-10-16 at 4 39 44 pm

@vudev vudev changed the title Xdebug: Waiting for incoming connection with ide key 'PHPSTORM' Xdebug: don't work Oct 20, 2017
@rodion-arr
Copy link

The same thing! Can't configure debugging in PhpStorm - it doesn't see any connections from Xdebug.

@vudev
Copy link
Author

vudev commented Oct 21, 2017

I think it conflict mac os high sierra

@rodion-arr
Copy link

OK, seems I solved the issue.

php-fpm section of docker-compose.yml is standard, no changes

php-fpm:
      build:
        context: ./php-fpm
        args:
          - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG}
          - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE}
          - INSTALL_SOAP=${PHP_FPM_INSTALL_SOAP}
          - INSTALL_MONGO=${PHP_FPM_INSTALL_MONGO}
          - INSTALL_MSSQL=${PHP_FPM_INSTALL_MSSQL}
          - INSTALL_ZIP_ARCHIVE=${PHP_FPM_INSTALL_ZIP_ARCHIVE}
          - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH}
          - INSTALL_PHPREDIS=${PHP_FPM_INSTALL_PHPREDIS}
          - INSTALL_MEMCACHED=${PHP_FPM_INSTALL_MEMCACHED}
          - INSTALL_OPCACHE=${PHP_FPM_INSTALL_OPCACHE}
          - INSTALL_EXIF=${PHP_FPM_INSTALL_EXIF}
          - INSTALL_AEROSPIKE=${PHP_FPM_INSTALL_AEROSPIKE}
          - INSTALL_MYSQLI=${PHP_FPM_INSTALL_MYSQLI}
          - INSTALL_TOKENIZER=${PHP_FPM_INSTALL_TOKENIZER}
          - INSTALL_INTL=${PHP_FPM_INSTALL_INTL}
          - INSTALL_GHOSTSCRIPT=${PHP_FPM_INSTALL_GHOSTSCRIPT}
          - INSTALL_LDAP=${PHP_FPM_INSTALL_LDAP}
          - INSTALL_SWOOLE=${PHP_FPM_INSTALL_SWOOLE}
        dockerfile: "Dockerfile-${PHP_VERSION}"
      volumes_from:
        - applications
      volumes:
        - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini
      expose:
        - "9000"
      depends_on:
        - workspace
      extra_hosts:
        - "dockerhost:${DOCKER_HOST_IP}"
      environment:
        - PHP_IDE_CONFIG=${PHP_IDE_CONFIG}
      networks:
        - backend

php.ini

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.remote_port=9000
xdebug.remote_host=YOUR_LOCAL_IP_ADDRESS
xdebug.idekey=PHPSTORM

Where YOUR_LOCAL_IP_ADDRESS is the value from ifconfig command. In my case it was in en0 section in inet row

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether ... 
	inet6 ... prefixlen 64 secured scopeid 0x5 
	inet HERE_IS_LOCAL_IP netmask 0xffffff00 broadcast ....
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active

PhpStorm settings:
1
2
3
4
5
6

Good luck!

@vudev
Copy link
Author

vudev commented Oct 26, 2017

I fixed it.

@tronghieu
Copy link

I have same issue

@jeff-h
Copy link
Contributor

jeff-h commented Nov 6, 2017

@tronghieu are you also using PHP Storm? I so I probably can't help, but I do have it running really well using Codebug as the client (macOS app similar to MacGDBp).

@tronghieu
Copy link

@jeff-h thank for your response. I'm using PHPStorm.

@dmz9
Copy link

dmz9 commented Mar 15, 2018

in case if someone (including me in future) trying to make it work.

  1. ./php-fpm/xdebug.ini (removed dbgp proxy - that was the problem for me)
; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)

; xdebug.remote_host=dockerhost
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1
  1. B,E,D>Deployment -
    akk.test is the alias of my dev domain (127.0.0.1)
    default
    keypair - doesnt work "out of the box" on ubuntu (some problems with ssh2, phpstorm shows notice at the bottom , whatever)
    fixed with this command
    puttygen insecure_id_rsa.ppk -O private-openssh -o insecure_fix
  2. don't forget to set up deployment path in "Mappings" tab
  3. L&F>PHP
    pick "cli interpreter" "..." button and add the php interpreter using deployment configuration.
    i did name it same as my dev domain
    also i did pick different (not default one) php version - php7.2
    default
  4. L&F>PHP>Debug
    debug port is 9000
    can accept external connections
  5. shut down & rebuild docker image for php-fpm
    i used this cheat code
    docker-compose down && docker-compose build php-fpm && docker-compose up -d nginx mysql php-fpm
    ===========
    thats all, next just set a breakpoint somewhere in the code, no need to create separate debug configuration (well, maybe it does for tests, didn't try) and start listening to xdebug

default

@jerfeson
Copy link

@rodion-arr Thanks bro

@zlanich
Copy link

zlanich commented Apr 24, 2018

@rodion-arr Wouldn't YOUR_LOCAL_IP_ADDRESS change all the time if you don't have your computer's networking settings set to static? I work on a laptop and jump on wifi all the time. There is so much unclear documentation in these issues right now for this PHPStorm issue, so I've spent hours rebuilding with no success.

Some guides say you need to use ssh-related configuration too to get this working, some don't. I'm so confused!

Some say use xdebug.remote_host=dockerhost instead of xdebug.remote_connect_back=1

@dmz9 Says to remove xdebug.remote_handler=dbgp

Currently running OSX High Sierra. Someone help me! :(

@jeff-h
Copy link
Contributor

jeff-h commented Apr 24, 2018

Here's the complete contents of my xdebug.ini; one copy inside each of php-fpm, php-fpm-services and workspace*, which is working perfectly for me.

I use it with Codebug — sorry if I'm convoluting a thread perhaps revolving around PHPSTORM oddities? Nonetheless I thought a working config might be a handy reference point.

; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.remote_port=9000
xdebug.remote_host=docker.for.mac.localhost
xdebug.idekey=PHPSTORM

I'm firmly in the "use xdebug.remote_host=dockerhost instead of xdebug.remote_connect_back=1" — I couldn't get the connect-back thing to work at all. Also you will note the docker.for.mac.localhost — also critical, in my setup at least.

Assuming you've set WORKSPACE_INSTALL_XDEBUG=true etc in your .env, this is what I did to rebuild after configuring the above stuff: $ docker-compose build workspace php-fpm php-fpm-services


*) only enable xdebug in the workspace container if you really need it; it slows down composer update massively.

@rodion-arr
Copy link

@zlanich Sure, you're right, this is the major flaw of the solution

@zlanich
Copy link

zlanich commented Apr 24, 2018

@jeff-h What is php-fpm-services? I don't have a container with that name, nor do I see any reference to it in the docs or laradock folder structure.

@zlanich
Copy link

zlanich commented Apr 24, 2018

@jeff-h Your config worked! Holy cow! That docker.for.mac.localhost was the magic ticket. I wish I understood the networking aspect of all of this better so I could help write documentation. I think I've probably spent at least 10% of my time as a developer just trying to get XDebug in PHPStorm to work 😂

@jeff-h
Copy link
Contributor

jeff-h commented Apr 25, 2018

Awesome — glad it helped :) I also feel like I spend ridiculous amounts of time getting this all set up, and keeping it that way. I definitely have a love/hate relationship with docker stuff. It's way too painful to setup, but way too awesome to give up.

Sorry about the php-fpm-services thing — I totally forgot that's one I invented for my own specific needs.

@zlanich
Copy link

zlanich commented Apr 25, 2018

No problem. This is the first time I've used Docker, but I've had my fair share of seemingly endless struggles getting PHPStorm + XDebug working over and over again lol. As I'm putting all this together, I'm eventually going to go back into the Laradock issues and post my found solutions on any of the relevant threads so other Mac users can hopefully benefit.

@runforrestrun
Copy link

runforrestrun commented Nov 17, 2018

With @jeff-h config,I managed to get it working to. Thanks dude.

Versions:
MacOs: 10.13.6
PHPStorm: 2018.2.5
Docker Engine: 18.06.1-ce

My laradock/php-fpm/xdebug.ini:

xdebug.remote_host=docker.for.mac.localhost 
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=1
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"

xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

PhpStorm, important, set this to laradock or whatever you have set for PHP_IDE_CONFIG:

screen shot 2018-11-17 at 15 42 24

@JamShady
Copy link

@jeff-h thank you, switching to use xdebug.remote_host=dockerhost instead of xdebug.remote_connect_back=1 solved my problem

@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Feb 2, 2020
@stale
Copy link

stale bot commented Feb 23, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants