gpt4 book ai didi

PhpStorm - 无法接受外部 Xdebug 连接

转载 作者:行者123 更新时间:2023-12-02 17:13:27 25 4
gpt4 key购买 nike

我在使用 Codeception 在 PhpStorm 中为我的应用程序运行测试时遇到错误。我的代码通过 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 设置中,我将其设置为接受外部连接:

enter image description here

在 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 错误并运行测试?

最佳答案

我能够通过将远程端口更改为未使用的端口(例如 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 设置中更新它:

enter image description here

关于PhpStorm - 无法接受外部 Xdebug 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47912870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com