Connection to Sqlite not established, unable to open database file

in Quick Bites


The problem

You created a new CakePHP application and you try to visit its homepage. You get a database error.

Missing Database Connection

Cake\Database\Exception\MissingConnectionException

Connection to Sqlite could not be established: SQLSTATE[HY000] [14] unable to open database file

The (potential) reason

Check your composer.json and see if your application uses cakephp/debug_kit:

"require-dev": {
    …
    "cakephp/debug_kit": "^4.4",
    …
}

By default, the CakePHP DebugKit plugin may be attempting to connect to Sqlite, and if that's not installed on your current server, you will be getting the above error.

The solution

Assuming your main database is MySQL.MariaDB, simply create a new database just for DebugKit.

'Datasources' => [
    'default' => [
        // your main database connection
    ],
    'debug_kit' => [
        'className' => \Cake\Database\Connection::class,
        'driver' => \Cake\Database\Driver\Mysql::class,
        'host' => '',
        'username' => '',
        'password' => '',
        'database' => 'debug_kit_database',
        'encoding' => 'utf8',
        'timezone' => 'UTC',
        'cacheMetadata' => true,
        'quoteIdentifiers' => false,
    ],
],
#cakephp #sqlite #cakephp-debug-kit