I've just started a fresh Laravel project, looking to approach it from a TDD point of view. With that in mind, I have setup a simple test, and as per the Birdboard series have set phpunit to use an sqlite database for testing in phpunit.xml
However, when I run my test, I get an error caused by:
PDOException: could not find driver
Sqlite is installed on my system (I went and got it and installed it) though the executable only works from the folder I extracted it to. How can I get it working with Laravel?
You can set it in the .env file at your root folder, under the name "DB_CONNECTION" and "DB_DATABASE". The second argument is the default value if the first one is not known.
@VILFAGO - That's missing the point. Firstly, it's not missing the database file, it's missing the driver for sqlite, period. Secondly, I don't want to use the same database for testing as for development, as per the Birdboard series. I don't want to fill my development database with test data. Hence using a temporary sqlite database for testing, or trying to.
I did enalbe die driver, still not working. On Windows command line it works (with enabled sqlite extension) but not on Ubuntu via WSL2 on command line so most likely conflicting PHP versions installed (find the right version of the ini file). So need to clean up the mess in WSL2 by removing all PHP versions and installing the right one or figuring out how enable only one specific version, editing its ini file and installing the correct PHP version of sqlite. Its clearly advanced stuff that can take you long time to figure out.
The only reason i use WSL2 is i can use curl but it is probably easier in the long term to set up a docker image with exactly one PHP version to not have pains for days due to such a dumb "dll hell"
@baumgars Windows and WSL2 are separate operating systems. The PHP in your Windows is in no way connected to the one in WSL. There's no "dll hell" in WSL because Linux binaries don't use DLL files.
All you need to do is install PHP's sqlite3 extension in WSL for whatever PHP version you're using. It's not advanced stuff, it's basic Linux usage.
If you're struggling with Linux while only using it for curl, why don't you just install curl in Windows?
Edit. I just checked: Windows already has curl installed by default.
What homework would that be, exactly? I already know how to install a package on Linux. And never in my career have I had a "conflict" in a php.ini file, whatever that means. Maybe you could explain what your conflict was, and how you got there?