简体   繁体   English

Drupal 8:使用XDebug和PHPStorm调试测试-逐步完成

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

I'm trying to debug my Drupal 8 tests with XDebug, but if I run them with XDebug switched on, I cannot step into the test. 我正在尝试使用XDebug调试我的Drupal 8测试,但是如果在打开XDebug的情况下运行它们,我将无法进入测试。 I execute the following command: 我执行以下命令:

vendor/bin/phpunit -c core modules/permissions_by_term/tests/src/Kernel/SelectTermTest.php vendor / bin / phpunit -c核心模块/permissions_by_term/tests/src/Kernel/SelectTermTest.php

PHPUnit reports me here: PHPUnit在这里向我报告:

"Can't find a source position. Server name 'localhost' doesn't exist." “找不到源位置。服务器名称'localhost'不存在。”

My settings in the PHP.ini file are looking as follows: 我在PHP.ini文件中的设置如下所示:

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

Can anybody share here some experience? 有人可以在这里分享一些经验吗?

I got it to run. 我让它运行。 I had to do some more settings. 我不得不做更多的设置。

First, create a new PHP Remote Debug under the Run Configurations (The ZeroConfiguration didn't work for me). 首先,在“运行配置”下创建一个新的PHP远程调试(ZeroConfiguration对我不起作用)。 Define a Server with the name you want (here "TestServer") and enter PHPSTORM as Ide Key. 用所需名称定义一个服务器(此处为“ TestServer”),然后输入PHPSTORM作为Ide Key。

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

Enable the option "Break at first line in PHP scripts" in under the RUN menu . 在“运行”菜单下启用“在PHP脚本的第一行中断”选项。

It can be possible that you need to override the file mapping. 您可能需要覆盖文件映射。 (In my case PHPStorm is not able to detect file mapping automatically) (See: https://www.jetbrains.com/help/phpstorm/10.0/override-server-path-mappings-dialog.html ). (在我的情况下,PHPStorm无法自动检测文件映射)(请参阅: https ://www.jetbrains.com/help/phpstorm/10.0/override-server-path-mappings-dialog.html)。 It's is within same dialog where the server was created. 它在创建服务器的同一对话框中。

Start the Remote Debug Session with clicking on the corresponding icon. 单击相应的图标启动远程调试会话。

Then you should be able to run PHPUnit with this command: 然后,您应该可以使用以下命令运行PHPUnit:

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

Set the PHP_IDE_CONFIG corresponding to your settings. 设置与您的设置相对应的PHP_IDE_CONFIG。

Set breakpoints where you want to stop. 在要停止的地方设置断点。

I hope I could help you. 希望能对您有所帮助。

Nico 尼科

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM