How to Install DebugKit on CakePHP

How to Install DebugKit for CakePHP (in just 4 easy steps!):

STEP 1 (option A): The traditional / download method:

Create a DebugKit folder within your app/Plugin directory, and put the contents of the download into it (not the top-level folder – the stuff within it). If you know how to clone from github, that works fine also.


STEP 1 (option B): The Composer method

This seems to currently be the most popular option (and for good reason). If you’re already using Composer [find out more about it here], then adding DebugKit is crazy-simple. If you haven’t used Composer before, don’t worry – just use “option A” above. The end-result is the same, and it’s easy too.

Ensure require is present in composer.json. This will install the
plugin into Plugin/DebugKit:

{
    "require": {
        "cakephp/debug_kit": "2.2.*"
    }
}

STEP 2:

Then, in your app/Config/bootstrap.php, add (or un-comment) the following line:

CakePlugin::load('DebugKit');

Lastly, in your app/Controller/AppController.php file (within the class), add:

public $components = array(
    'DebugKit.Toolbar'
);

(If you already have a $components array, then just add to it – don’t re-set it.)


STEP 3: Ensure debug is 1 or more

In your Config/core.php file, make sure this line:

Configure::write('debug', 2);

has a value of 1 or 2. (read more about debug mode here)


STEP 4: Remove sql_dump:

In your layout file, remove the ‘sql_dump’ element (at the bottom of the default layout)


According to the “Installation” section on the debugKit page:

  • Clone/Copy the files in this directory into app/Plugin/DebugKit
  • Ensure the plugin is loaded in app/Config/bootstrap.php by calling CakePlugin::load(‘DebugKit’);
  • Include the toolbar component in your AppController.php:
    public $components = array(‘DebugKit.Toolbar’);
  • Set debug mode to at least 1.
  • Make sure to remove the ‘sql_dump’ element from your layout if you want to experience the awesome that is the debug kit SQL log.

How do I know if it’s working?

You should see a small icon on a gray square in the upper right corner of your site. Click on this to expand the options, then click on an option to start being awesome.

Leave a Comment