【问题标题】:PhpStorm - Cannot accept external Xdebug connectionPhpStorm - 无法接受外部 Xdebug 连接
【发布时间】:2018-06-03 10:00:45
【问题描述】:

我在 PhpStorm 中使用 Codeception 为我的应用程序运行测试时出错。我的代码正在通过 Vagrant 运行。

在 Codeception 测试的 index.php 的第一行是:

ini_set('xdebug.max_nesting_level', 200);

我通过自制软件安装了 xdebug,这在我的 php 版本输出中:

PHP 7.1.12 (cli) (built: Dec  2 2017 12:15:25) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans   

当我在 PhpStorm 事件日志中收到错误时运行测试时:

Cannot accept external Xdebug connection: Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])'

在我的 PhpStorm 设置中,我将其设置为接受外部连接:

在 php 信息中我有可用的 xdebug 设置:

$ php -i | grep xdebug                 
Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
...
xdebug.remote_connect_back => On => On

/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini中我根据this thread设置xdebug.remote_connect_back=1

我该怎么做才能消除Cannot accept external Xdebug connection 错误并运行测试?

【问题讨论】:

  • 嗯,$_SERVER['PHP_IDE_CONFIG'] 我认为是用于远程 CLI 调试的。缺少idekey? xdebug.idekey="PHPSTORM"。已经读过了? stackoverflow.com/questions/29035705/…我的工作,但我必须点击绿色的小电话按钮“听”,
  • 设置 idekey 未修复或更改错误。我确实有监听调试连接的绿色电话
  • 因此,使用这种方法,您将在请求中提出一个标志,告诉 IDE 进行处理。看请求,请求中的变量是怎么传入的?当我想在 IDE 中调试时,我想我已经使用了浏览器工具栏按钮来添加它。

标签: php debugging phpstorm xdebug codeception


【解决方案1】:

就我而言,(使用 Symfony 框架和 PhpStorm )它只是与我必须清理的一些缓存有关!我花了 2 个小时才弄清楚,因为我已经配置并正确设置了所有内容,但事件仍然没有启动。

因此,当您遇到此类无能为力的问题时,请始终清除现金:如果它不起作用,则继续执行其他步骤以调试问题的根源。

【讨论】:

    【解决方案2】:

    我可以通过将远程端口更改为未使用的端口(例如 9898)来解决此问题:

    [xdebug]
    zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
    xdebug.remote_enable=1
    xdebug.remote_connect_back=1
    xdebug.idekey="PHPSTORM"
    xdebug.remote_port = 9898
    

    然后在 PhpStorm 设置中更新:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-13
      • 2016-10-01
      • 2015-08-03
      • 2023-03-31
      • 2018-04-27
      • 2015-09-25
      • 1970-01-01
      • 2020-09-23
      相关资源
      最近更新 更多