How To Make Sqlite Work In Laravel
Solution 1:
Short Solution
Though not answering the question, the way to fix "Database not found" issue is to replace the following line in database.php:
'database' => env('DB_DATABASE', database_path('database.sqlite')),
with
'database' => database_path('database.sqlite'),
Solution 2:
By using the relative path, migrations will fail because they use project directory as root directory...
To correct everything, I suggest setting:
DB_DATABASE=database\database.sqlite
and tweaking the sqlite connections in config/database.php as follows:
'database' => env('DB_DATABASE/..', database_path('database.sqlite')),
Original Answer
The .env file should contain this:
DB_DATABASE=..\database\database.sqlite
With some testing you can verify that the link included in DB_DATABASE
is relative to the 'public' directory (at least on my Windows machine). That's why we should introduce ..\ before your link.
And of course, using an absolute link should do it too:
DB_DATABASE=D:\www\project\database\database.sqlite
as @Josh suggests
Solution 3:
Complementing the awnser by our friend @alexander-lomia
Change:
'database' => env('DB_DATABASE', database_path('database.sqlite'))
To:
'database' => database_path(env('DB_DATABASE'))
in database.php
:)
Solution 4:
Create file called
database.sqlitein this folder asdatabase/database.sqliteOpen the
.envfile and change MySQL to SQLiteComment password and username and databaseName using '#'
run
php artisan migrateenjoy
env file like this:
DB_CONNECTION=sqlite
#DB_HOST=127.0.0.1#DB_PORT=3306#DB_DATABASE=database#DB_USERNAME=homestead#DB_PASSWORD=secretSolution 5:
Instead of a relative path you need to use an absolute path in your .env file.
DB_DATABASE=/var/www/project/database/database.sqlite
or in your case:
DB_DATABASE=D:\www\project\database\database.sqlite
Post a Comment for "How To Make Sqlite Work In Laravel"