Xdebug: [Step Debug] 无法连接到调试客户端 [英] Xdebug: [Step Debug] Could not connect to debugging client

查看:436
本文介绍了Xdebug: [Step Debug] 无法连接到调试客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试 Xdebug 3.0.0RC1 来探索发生了什么变化以及随之而来的新功能.我也在使用最新的 PhpStorm 2020.3 EAP,它支持 Xdebug 3,不需要主要配置.下面是我的调试器的 PhpStorm 配置:

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 with no major config needed. Below is my PhpStorm config for the Debugger:

这是我为 Xdebug3 尝试的配置:

And here is the configuration I have tried for Xdebug3:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal # here I tried several combinations like: "localhost", "127.0.0.1", "172.17.0.1"
xdebug.client_port=9001 # here I tried several ports 9003 included with no success

我也试过根本不添加 client_host/client_port 设置,但仍然失败.

I have also tried not adding the client_host/client_port setting at all and still failing.

我收到此错误:

Script php bin/console doctrine:cache:clear-metadata returned with error code 255
!!  [17-Nov-2020 15:24:40 UTC] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9001 (through xdebug.client_host/xdebug.client_port) :-(
!!  [17-Nov-2020 15:24:41 UTC] PHP Fatal error:  Method class@anonymous::__toString() must not throw an exception, caught Symfony\Component\DependencyInjection\Exception\AutowiringFailedException:  in /var/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php on line 233

关于我的环境的一些信息:

Some info about my environment:

  • Fedora 33
  • Docker 版本 19.03.13,内部版本 4484c46d9d
  • PhpStorm 2020.3 EAP 版本 #PS-203.5784.36

这很奇怪(因为显然 host.docker.internal 我正在使用的 Docker 版本不"支持但它可以工作)并且很奇怪,同时以下配置确实使用 Xdebug 2 甚至让调试器一直监听传入的连接:

It is curious (because apparently host.docker.internal is "not" supported by the Docker version I am using and yet it works) and weird at the same time that the following configuration does work with Xdebug 2 even having the debugger listening for incoming connections all the time:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_autostart=0
xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_port=9000

我在这里缺少什么?

注意:我已经在此处应用了 Xdebug 开发人员提供的解决方案.

Note: I already applied the solution provided by the Xdebug developer here.

推荐答案

PHP 7.4
码头工人
PHPStorm 2020.1
Xdebug 3.1.0

PHP 7.4
Docker
PHPStorm 2020.1
Xdebug 3.1.0

使用 Dockerfile 在您的 docker 容器中安装 Xdebug

Install Xdebug in your docker container using Dockerfile

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

使用以下内容配置 php.ini:

Configure php.ini with following:

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

转到 PHPStorm - Settings - PHP - Debug - Xdebug 并将端口设置为 9003(默认)

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

PHPStorm

就是这样(:

如果您只想在需要时启用/禁用调试器:只需安装名为Xdebug helper"的浏览器扩展,选择Debug";并删除xdebug.start_with_request = yes";来自 php.ini

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

这篇关于Xdebug: [Step Debug] 无法连接到调试客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆