How to show DebugKit on CakePHP 3?

So you see on the install page that DebugKit is loaded. But nothing appear to the bottom of the screen? We could solve that in only three steps.

Step 1 – Create a new database

Go to mysql, postgresql or what you use and then create a new database with the name of your choice ( example : debug_kit ).

Step 2 – Open config/app.php and add a new connection

In config/app.php file search :

'Datasources' => [
        'default' => [...]
]

And just copy paste all the ‘default’ block and name connection ‘debug_kit’.
Also change the username, password, and finally the database with this one you’ve created juste before.

'Datasources' => [
        'default' => [...],
        'debug_kit' => [
            ...
            'username' => 'my_app',
            'password' => 'secret',
            'database' => 'debug_kit',
            ...
        ]     
]

Step 3 – Open config/bootstrap.php and add this

Under version 3.6

Just check to the bottom if you have this lines, if not just copy paste.

if (Configure::read('debug')) {
    Plugin::load('DebugKit', ['bootstrap' => true]);
}

Version 3.6.x

From this version, if the DebugKit doesn’t show up, it’s for two reasons.
The first, DebugKit is not loaded by default in bootstrap file and second reason it’s maybe cause you use an unusual extension in your domain name like .lan, .foobar …

The authorized extension in the core are :

['localhost', 'dev', 'invalid', 'test', 'example', 'local']

So if you’re like me and use an .lan extension you must add one line in bootstrap file.

if (Configure::read('debug')) {
    Configure::write('DebugKit.safeTld', ['lan', 'foobar']);
    Plugin::load('DebugKit', ['bootstrap' => true]);
}

Bonus: fix deprecated code in 3.7.x version

In 3.7 version Plugin::load is deprecated, so use this :

if (Configure::read('debug')) {
    Configure::write('DebugKit.safeTld', ['lan', 'foobar']);
    \App\Application::addPlugin('DebugKit', ['bootstrap' => true]);
}

And now the DebugKit tool must be appear like magic.

This Post Has One Comment

  1. dwi

    Cool! It’s work! Thank you…

Leave a Reply