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?
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 ofphp 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.
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:
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.