Xdebug of Laravel Dusk in Netbeans on Homestead

2019-02-27 13:54发布

In Laravel Homestead, I've been able to use Xdebug for unit tests, feature tests, poking around in the browser, etc.

But it hangs when I try to use Xdebug for Dusk (tests in tests/Browser folder).

I thought these questions might help, but I still haven't gotten it working:

I've tried various approaches, including:

export XDEBUG_CONFIG="idekey=netbeans-xdebug remote_connect_back=0 remote_host=10.0.2.2"
php artisan dusk

and

export XDEBUG_CONFIG="idekey=netbeans-xdebug remote_host=10.0.2.2"
php -dxdebug.remote_autostart=on -dxdebug.remote_connect_back=off -dxdebug.remote_host=10.0.2.2 artisan dusk

and more.

I've enabled the "Stop at First Line" debugging option in Netbeans, and Netbeans does successfully stop at the first executable PHP line in the artisan file.

Therefore I think export XDEBUG_CONFIG="idekey=netbeans-xdebug remote_connect_back=0 remote_host=10.0.2.2" is correctly set up.

But after I click the "play" button to allow the code to continue, Netbeans just says "netbeans-xdebug running" in the bottom right while the console just hangs with a cursor flashing under this line: php artisan dusk tests/Browser/ExampleTest.php

How do I need to change my usage of Xdebug for getting it to work in Dusk too?

2条回答
Lonely孤独者°
2楼-- · 2019-02-27 14:14

It doesn't work because Dusk executes the actual PHPUnit test in a separate process, so it doesn't know about XDEBUG_CONFIG.

In principle, Dusk tests still work when you execute them directly (phpunit tests/Browser/ExampleTest.php). The main feature of php artisan dusk are custom .env.dusk[.local] files.

If you don't require that, you can try calling them directly. Then Xdebug should behave the same way it does with all your other PHPUnit tests.

查看更多
虎瘦雄心在
3楼-- · 2019-02-27 14:15

As in my answer here, there is an option of running php -dxdebug.remote_enable=1 -dxdebug.remote_host=10.0.2.2 -dxdebug.remote_port=9000 -dxdebug.remote_handler=dbgp artisan my:command

You can also add those parameters to xdebug.ini like so:

zend_extension_ts = "./php/ext/php_xdebug<-version-number>.dll"
xdebug.remote_enable=1
xdebug.remote_host=10.0.2.2
; Port number must match debugger port number in NetBeans IDE Tools > Options > PHP
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

xdebug.idekey=netbeans-xdebug (although I think it should work without this too)

Try removing break at first line option. Also try running debug directly from console with those options. And finally check that the correct port is set to listen in NetBeans and xdebug since that could cause problems too.

查看更多
登录 后发表回答