Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SeanKimball's avatar

Laravel 11, artisan test and xdebug

Having an issue with xdebug showing the code coverage in a laravel 11 project.

artisan test --coverage

only shows the code coverage if I specify a directory

artisan test --coverage ./coverage/

Which would normally be fine but it does not run the (unit or feature) tests if --coverage is applied nor does it actually check the coverage, i.e. it lists all my controllers and models, but lists all coverage as 0% even if there are tests for that model/controller.

xDebug is definitely installed - it kind of works, and I don't see any documentation or reason as to why it would need a directory to (incorrectly) generate a report.

Anyone have any help with this?

0 likes
4 replies
Tray2's avatar

If you are using Laravel Herd, you can just add

zend_extension=/Applications/Herd.app/Contents/Resources/xdebug/xdebug-83-x86.so
xdebug.mode=develop,coverage
xdebug.start_with_request=yes
xdebug.start_upon_error=yes

To your php.ini.

1 like
SeanKimball's avatar

@Tray2 Thanks - but no, I am running apache/php/etc in a local WSL2 container. Herd does not look like it fits my bill.

Tray2's avatar

@SeanKimball The settings in the php.ini are the same though, except for the path.

I suggest using Herd though, it will make things a lot easier.

SeanKimball's avatar

The setting are the same, it is setup correctly - it's just not behaving as expected. I'm wondering if it is supposed to run both tests and coverage at the same time at all - I think artisan is doing something odd.

Please or to participate in this conversation.