Sometimes you may decide you want to use SQLite for your Laravel app instead of a full blown MySQL database. In that case setting it up is pretty simple. Following the instructions in the Laravel docs, first you need to set up a SQLite database by running this command in Terminal:
Then you have to edit your .env file with the following details:
So that is really the only tricky bit. I remove all the DB settings in the .env file and replace them with the above. If you don’t know what your absolute path is then it will look something like this:
Alternatively, you the default in the config/database.php file is:
'sqlite' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ],
So you can just remove all DB settings from .env and it should also work. DOn’t forget to change the database setting to be:
'default' => env('DB_CONNECTION', 'sqlite'),
And that should do it. You can now use SQLite in your app the same way you would MySQL.