【问题标题】:How to run XDebug with PHPUnit from the command line?如何从命令行使用 PHPUnit 运行 XDebug?
【发布时间】:2013-09-06 10:03:52
【问题描述】:

我有 netbeans 在调试模式下运行。现在我想使用 ?XDEBUG_SESSION_START=netbeans-xdebug 运行单元测试,目标是在运行时设置断点。有可能吗?

我尝试过这样的事情:

phpunit myTest.php?XDEBUG_SESSION_START=netbeans-xdebug

不起作用。有什么想法吗?

更新

据此:http://blog.doh.ms/2011/05/13/debugging-phpunit-tests-in-netbeans-with-xdebug/

转到命令行并运行 phpunit-debug。现在开始调试,如果你选择了“Stop on first line”,你的IDE会打开phpunit文件,点击play就可以了。

如果我运行 phpunit --debug

Starting test 'xxxx'
OK (1 test, 4 assertions)

问题是,它从未捕获我在控制器中的断点。为什么抓不到呢?是否有可能是因为它是使用以下方式执行的:

$this->dispatch('/ajax/update-bla');

【问题讨论】:

    标签: windows netbeans phpunit


    【解决方案1】:

    试试这个
    $ XDEBUG_CONFIG="idekey=netbeans-xdebug" phpunit -c %yourconfing%.xml

    或者您可以导出 shell var
    $ export XDEBUG_CONFIG="idekey=netbeans-xdebug"

    然后像往常一样运行 phpunit
    $ phpunit -c %yourconfing%.xml

    【讨论】:

    • 另外你也可以创建一个phpunit-debug bash loader,非常有用:stephenrhoades.com/?p=600
    • 我不明白。这必须在终端上运行吗?配置文件有什么对调试工作很重要的东西?