HUGE_DICK_10_INCHES's avatar

How to set database path in eloquent connection method

I am getting problem with setting path to sqlite path database.

use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule();

$capsule->addConnection([
    'driver' => 'sqlite',
    'database' => './dbdata/db.sqlite',
]);

$capsule->setAsGlobal();
$capsule->bootEloquent();

File with this code and dbdata folder are on same path, so I tried adding ./dbdata/{name of sqlite file}, any help how to make connection with sqlite db? (This is out of the laravel)

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

Pretty sure you need the full filesystem path to the file.

Don't forget that the folder needs to be writable by the web server, and by the user running artisan, and you should create an empty file to start with.

Please or to participate in this conversation.