Error trying to connect Yii2 with SQLite

0

I am trying to connect my application in Yii2 with a SQLite database but every time I try to access my application I get the following error: The configuration for the "db" component must contain a "class" element.

This is how I have my database connection in SQLite

return [ 'components' => [
'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'sqlite:/softwareoperacional.db', ],
], ];

    
asked by Sebastian Salazar 24.02.2018 в 05:15
source

1 answer

1

Followed by the sqlite: you must specify the path and name of the sqlite database, like this:

Locate the database ( dbsqlite.d b) within my project, in the web \ sqlitedb folder.

>

db.php

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'sqlite:C:\xampp\htdocs\YII2_basic\web\sqlitedb\dbsqlite.db',
   ];

or specifying in this way:

 'dsn' => 'sqlite:@webroot/sqlitedb/dbsqlite.db',
    
answered by 24.03.2018 / 00:04
source