Xdebug: [Step Debug] Could not connect to debugging client

后端 未结 3 1239
余生分开走
余生分开走 2021-02-20 17:47

I would like to try Xdebug 3.0.0RC1 to explore what has changed and the new features that come with it. I am also using the latest PhpStorm 2020.3 EAP which supports Xdebug 3 wi

相关标签:
3条回答
  • 2021-02-20 17:48

    I had the same issue. I still have it when doing a request from a browser, but from the commandline, like in your case, it now works. What I was missing was a Server configuration with a path mapping. Once it set that up, along with the settings that you already have, it worked. I am on Mac Os Big Sur, using PhpStorm 2020.3

    0 讨论(0)
  • 2021-02-20 18:05

    PHP 7.4
    Docker
    PHPStorm 2020.1
    Xdebug 3.1.0

    Install Xdebug in your docker container using Dockerfile

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

    Configure php.ini with following:

    [xdebug]
    xdebug.mode = debug
    xdebug.start_with_request = yes
    xdebug.discover_client_host = 1
    

    Go to PHPStorm - Settings - PHP - Debug - Xdebug and set the port to 9003 (by default)

    PHPStorm

    That's it (:

    If you want to enable/disable debugger only when you need it: just install a browser extension called "Xdebug helper", select "Debug" and remove "xdebug.start_with_request = yes" from php.ini

    [xdebug]
    xdebug.mode = debug
    xdebug.discover_client_host = 1
    
    0 讨论(0)
  • 2021-02-20 18:10

    I will start saying big thanks to @LazyOne who spent some time helping me on this one until we make it to work. Here is how the config looks like for me currently and it is working fine:

    zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
    xdebug.mode=debug
    xdebug.client_port=9005
    

    You need also to update the Xdebug port at File | Settings | Languages & Frameworks | PHP | Servers to reflect the new one but also enable the option to listen on Xdebug3 incoming connections. (I believe it is enabled by default in PhpStorm 2020.3)

    That is the setup for a backend project where no browser is in the middle, I have not tried but for those, you might need:

    xdebug.start_with_request=yes
    

    And also have File | Settings | Languages & Frameworks | PHP | Servers well configured.

    Note: We found the host had enabled IPv6 and I disabled it and in addition, added the following setting to the IDE through Help > Edit Custom VM options: -Djava.net.preferIPv4Stack=true. After added the IP4 setting to the IDE I haven't tried re-enabling IPv6 and see if Xdebug 3 still working

    0 讨论(0)
提交回复
热议问题