doumingo04696 2016-07-15 09:42
浏览 148
已采纳

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

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. I execute the following command:

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

PHPUnit reports me here:

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

My settings in the PHP.ini file are looking as follows:

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?

  • 写回答

1条回答 默认 最新

  • douqianke7467 2016-08-05 08:46
    关注

    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). Define a Server with the name you want (here "TestServer") and enter PHPSTORM as Ide Key.

    Also see the Jetbrains documentation: 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 .

    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). 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:

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

    Set the PHP_IDE_CONFIG corresponding to your settings.

    Set breakpoints where you want to stop.

    I hope I could help you.

    Nico

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系