DebugKit 4 in CakePhp4

Hi everyone,

I’m using CakePHP4 and try to enable DebugKit. I followed the instructions in the cookbook and installed DebugKit via

php composer.phar require --dev cakephp/debug_kit "~4.0"

I have created a ‘debug_kit’ connection in my app_local.php, Datasources.
I do have a working MySQL for my application as such as the default datasource - and it’s working fine.

I have enabled DebugKit via

Configure::write('DebugKit.ignoreAuthorization', true); Configure::write('DebugKit.forceEnable', true); $this->addPlugin('DebugKit');

My expectation would be, DebugKit loads and uses the provided DebugKit connection / database.
Actually i’m now getting an error, which looks as if DebugKit is not using the connection, but still tries to use sqlite:

# Database driver Cake\Database\Driver\Sqlite cannot be used due to a missing PHP extension or unmet dependency

Am i missing something? Do i have to somehow disable Sqlite usage for DebugKit / force database/mysql usage?

As the error says you are missing the SQLite PHP extension.
You need to search for how to install SQLite PHP extension for your setup / operating system.

Hi Kevin, thanks for the reply. Maybe i did not make myself clear, sorry for that, trying again:
I do NOT want to use sqlite - and the cookbook documentation says on that matter:

By default DebugKit will store panel data into a SQLite database in your application’s tmp directory. If you cannot install pdo_sqlite, you can configure DebugKit to use a different database by defining a debug_kit connection in the Datasources variable in your config/app.php file.

So I am assuming, i can just define the data source and then DebugKit will automatically not use SQLite but my MySQL DB instead.

As described in the beginning, i have defined that connection. However, i’m still seeing DebugKit to trying to go for SQLite. What am i missing?

Looking at debug_kit/bootstrap.php at 458a3bb2db282edc7cb64d95e14f6b3c69658201 · cakephp/debug_kit · GitHub it seems like you still need the pdo_sqlite extension

@ADmad what do you say about that? I guess the doc is missleading because the debug kit still requires the sqlite extension even if a non sqlite connection is set in the apps config.

ah sorry, I missread the if. It only gets in there when no user config is set.

@stefan.hegenbart are you sure you didn’t specify 'driver' => 'Cake\Database\Driver\Sqlite', as the driver in your custom debug_kit datasource (or any other datatsource)?

i copied the sample connection from the cookbook. It includes mysql as driver. Here’s what’s in my app_local.php as part of my dataconnections:

         * The debug_kit connection stores DebugKit meta-data.
         'debug_kit' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => '',
            //'port' => 'nonstandard_port_number',
            'username' => '#myuser',    // Your DB username here
            'password' => '#mypassword',    // Your DB password here
            'database' => '#mydb',
            'encoding' => 'utf8',
        //    'timezone' => 'UTC',
            'cacheMetadata' => true,
            'quoteIdentifiers' => false,
             //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],

If its not that cconnection it has to be another one.
The error message is exactly the one from cakephp/MissingExtensionException.php at 4.x · cakephp/cakephp · GitHub

Which only gets thrown in cakephp/Connection.php at 4.x · cakephp/cakephp · GitHub

Therefore try to search your app (not the vendor directory) for any occurences of Cake\Database\Driver\Sqlite

If there are none then its probably a Plugin you are using.

I just tried using a custom database connection WITHOUT the SQLite PHP extension installed and everything works flawlessly for me.

Ok, thanks for looking into it. Let me try to find out what’s going on.

With regards to plugins I’m only using vanilla cakephp + auth plugin + debugkit I have not yet added something else. The application works well - until i’m activating debugkit.

Just to be sure: I need to add the debug kit connection in app_local - same place where I’m also adding my other data connections for my application?

Yes, its fine to add it to your config/app_local.php since it is merged with the “normal” config here:

You can also apply those changes manually in your vendor/cakephp/cakephp folder to get a more telling error.

The next CakePHP release will contain the connection name which requires the missing PHP extension and therefore debugging your problem will be easier.

Thanks so much - i implemented the fix and found the traitor:

My observations:

  • “test” connection indeed is sqlite - but to my knowledge, no module of my app is using the connection. I’m not employing the test suite.
  • this only happens, when i activate debug_kit - when debug_kit is not activated, the app runs smoothly (apparently ignoring / not using the test connection)
  • having debug_kit enabled and then just deleting “test” connection makes my app work again AND have debug_kit up and running :slight_smile:

I’d still be into finding out, what component is trying to use the test connection (or is it debug_kit?). Maybe that would be even an addition to the error message? So not only the connection - but also who used the connection?

So it was my “test” connection in the app_local. But it seems like it’s not been checked explicitely - as i can rename the “test” connection to “someconnection” and problem remains. This is reproducible in a fresh install.

Is there any functionality in Debug_Kit probing all available connections?

Ok, I think now I get your problem.

Here the Debug Kit SQL Panel iterates over all available Datasources, including the test database.

And since the driver for that datasource isn’t available for you you should also set that to Cake\Database\Driver\Sqlite to fix your problem.

Basically calling ConnectionManager::get($name); with that Datasource name as a parameter it will initialise that connection and therefore also check if the set driver is available or not.

1 Like

Understood. Solution for me will be easy, i commented out the test connection as i’m not using it.

Looking at the documentation in CakePHP Cookbook for Debug_Kit, the paragraph on Database Configuration is indicating, that only changing the Debug_Kit connection to MySQL should be sufficient (sqlite being absent). However, the “Test” connection is a default connection when initially setting up CakePHP. Chances are, other people not having sqlite run in the same problem initially.

There could either be a hint like “Debug_Kit will initialize all connections, please check for any other sqlite based one.” What do you think?


To be fair it is very unusual that your php environment doesnt have the mysql extension installed. Every shared hoster depends/supports it.
And even if you have a custom server this extension is installed in 1 command.

Ok, I was not aware of that. I know I can install it, it’s just not there by default. I agree: if affected audience is limited and my case is more of an exception, there’s no urgent need for a change. :slight_smile:

Anyway, I’m grateful for your help and that it’s working now.