# Toolbar Panels
The debugKit Toolbar is comprised of several panels. Each panel is comprised of a panel class and view element. Typically a panel handles the collection and display of a single type of information such as Logs or Request information. You can choose to panels from the toolbar or add you own custom panels.
### Built-in Panels
There are several built-in panels. They are
* **History** Allows access to previous request information, useful when debugging actions with redirects.
* **Request** Displays information about the current request, GET, POST, Cake Parameters, Current Route information and Cookies if the ```CookieComponent``` is in you controller's components.
* **Session** Display the information currently in the Session.
* **Timer** Display any timers that were set during the request see [wiki:debugkitdebugger DebugKitDebugger] for more information. Also displays memory use at component callbacks as well as peak memory used.
* **Sql Logs** Displays sql logs for each database connection.
* **Log** Display any entries made to the log files this request.
* **Variables** Display View variables set in controller.
### Configuring Panels
You can customize the toolbar to show your custom panels or hide any built-in panel when adding it toolbar to your components.
var $components = array('DebugKit.Toolbar' => array(
'panels' => array('customPanel', 'timer'=>false)
)
);
Would display your custom panel and all built-in panels except the 'Timer' panel.
### Creating your own Panels
You can create your own panels as well to provide custom debugging information for your application. Custom panels need to subclass the `DebugPanel` class. Panel objects have 2 callbacks that allow them to hook into and introspect on the current request.
startup(&$controller)
Each panel's `startup()` method is called during component `startup()` process. `$controller` is a reference to the current controller object.
beforeRender(&$controller)
Much like ```startup()``` ```beforeRender()``` is callled during the Component beforeRender() process. Again ```$controller``` is a reference to the current controller. Normally at this point you could do additional introspection on the controller. The return of a panels ```beforeRender()``` is automatically passed to the View by the Toolbar Component. Therefore, under normal use you do not need to explicitly set variables to the controller.
#### File location and naming convention
Panel Classes simply need to be placed in a vendors folder. The filename should be the lower case and underscored version of the class name with _panel. So the class ```MyCustomPanel``` would be expected to have a filename of ```my_custom_panel.php```.
#### Example of beforeRender callback
/**
* beforeRender callback - grabs request params
*
* @return array
**/
function beforeRender(&$controller) {
return $controller->params;
}
This would return cake's internal params array. The return of a panel's `beforeRender()` is available in you Panel element as `$content`
#### Using panels from plugins
Panels provided by plugins work almost entirely the same as other plugins, with one minor difference. You must set `var $plugin` to be the plugin name directory. This must be done so that the element can be located at rendering time.
To use a plugin panel, use the common CakePHP dot notation for plugins.
{{{
var $components = array('DebugKit.Toolbar' => array(
'panels' => 'MyPlugin.Custom'
));
}}}
The above would load all the default panels as well as the custom panel from MyPlugin.
#### Panel Elements
Each Panel is expected to have a view element that renders the content from the panel. The element name must be the underscored inflection of the class name. For example `SessionPanel` has an element named `session_panel.ctp`, and sqlLogPanel has an element named `sql_log_panel.ctp`. These elements should be located in the root of your `views/elements` directory. If you are creating panels as part of your plugin see "Using panels from other plugins".
