Drupal 8:使用 XDebug 和 PHPStorm 进行调试测试 - cennot 单步执行

Drupal 8: Debugging tests with XDebug and PHPStorm - cennot step through

我正在尝试使用 XDebug 调试我的 Drupal 8 测试,但是如果我 运行 在打开 XDebug 的情况下进行测试,我将无法进入测试。我执行以下命令:

vendor/bin/phpunit -c core modules/permissions_by_term/tests/src/Kernel/SelectTermTest.php

PHPUnit 在这里报告我:

"Can't find a source position. Server name 'localhost' doesn't exist."

我在 PHP.ini 文件中的设置如下所示:

xdebug.remote_enable=true xdebug.profiler_enable=0 xdebug.idekey=PHPSTORM xdebug.max_nesting_level=256 xdebug.remote_autostart=true

谁能在这里分享一些经验吗?

我做到了 运行。我不得不做一些更多的设置。

首先,在 运行 配置下创建一个新的 PHP 远程调试(ZeroConfiguration 对我不起作用)。使用您想要的名称定义服务器(此处为 "TestServer")并输入 PHPSTORM 作为 Ide 键。

另请参阅 Jetbrains 文档:https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+Web+Applications+with+Run+Debug+Configurations

启用 运行 菜单下的选项 "Break at first line in PHP scripts"。

您可能需要覆盖文件映射。 (在我的例子中 PHPStorm 无法自动检测文件映射)(参见:https://www.jetbrains.com/help/phpstorm/10.0/override-server-path-mappings-dialog.html)。它位于创建服务器的同一对话框中。

单击相应的图标启动远程调试会话。

那么你应该可以运行 PHP单位用这个命令:

PHP_IDE_CONFIG="serverName=TestServer"  XDEBUG_CONFIG="idekey=PHPSTORM" vendor/phpunit/phpunit/phpunit -c YOUPHPUNITXMLCONFIG

根据您的设置设置PHP_IDE_CONFIG。

在要停止的地方设置断点。

希望能帮到你

妮可