Categories
Laravel

Database Laravel Tests failing from Sail App

Ok, this was a silly error on my part, because I got out of practice using the sail commands.

I have a Laravel app running on Sail/Docker under WSL. The app worked through the browser, but there was no DB access from the CLI or running tests.

I was running php artisan test which was using the PHP local to the WSL system, and not the virtual PHP server which should run the app. The WSL PHP happened not to have the PDO driver installed, so DB access failed.

Just needed to run the command properly as sail art test to use the correct PHP (I have aliased art to artisan).

Problem solved.