DebugKit plugin for Croogo

Posted by Fahad on Mon, Sep 06 2010

If you are a CakePHP developer, you must know about DebugKit plugin by Mark Story already. It provides a debugging toolbar and enhanced debugging tools for CakePHP applications. As far as I remember, it is the first plugin I tried in my applications and this may be the case for most developers too.

So why am I posting it here again? Just to demonstrate how it can be used with Croogo's plugin/hook system. A few weeks ago, I forked DebugKit and made it Croogo ready so anyone can upload it from the admin panel and start using it without having to worry about editing php files (app_controller.php here) manually.

All I did was add two files under a new directory 'config' to this awesome plugin, and done! First was an YAML file and the other was a PHP file. The file structure looks like this:

  • /app/plugins/debug_kit/
    • config (the new directory)
      • debug_kit_bootstrap.php
      • plugin.yml
    • controllers/
    • models/
    • views/
    • ...
    • debug_kit_app_controller.php
    • debug_kit_app_model.php

The YAML file

plugin.yml file is used for storing basic information about the plugin like it's description, author's name, website, etc. It can also contain information like it's dependencies. But we don't need anything like that for this plugin now:

name: DebugKit
description: DebugKit plugin

author: Mark Story
authorEmail:
authorUrl: http://mark-story.com

The plugin's bootstrap file

debug_kit_bootstrap.php is loaded every time the application bootstraps (only when the plugin is active). It handles configuration so DebugKit's Toolbar component is loaded in every controller.

<?php Croogo::hookComponent('*', 'DebugKit.Toolbar'); ?>

If you wanted the component to load only in, say, Users controller:

<?php Croogo::hookComponent('Users', 'DebugKit.Toolbar'); ?>

That wasn't too difficult, right? Now you can log in to Croogo's admin panel and activate the plugin from Extensions > Plugins page and you will see the toolbar at top right of your browser immediately. You can also deactivate it once you are done with debugging.

To learn more about how plugins work in Croogo, read the wiki.

Download

Get the modified version of DebugKit from http://github.com/fahad19/debug_kit.

Posted in Croogo, Plugins

3 Comments

John74 said on May 05, 2011
Thank you, this is really helpfull !
Paul Gardner said on Oct 02, 2011
Hi Fahad,

Eventually gotten around to trying out Croogo after seeing you demo it at CakeFest.

Naturally, the first plugin I have tried to install is DebugKit. I downloaded the zip file from GitHub, uploaded it via the Croogo admin but it does not appear in the list of plugins to be activated.

/app/plugins/debug_kit has been created so I tried adding the DebugKit.Toolbar to components and got a View::layout could not be found.

Any ideas?
Paul Gardner said on Oct 02, 2011
For some reason when uploading via Croogo admin it was creating the wrong folder structure.

Manually unzipped the package into /app/plugins and it appeared in the Plugins list. Activated it and the toolbar appeared, great!

Add new comment