| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
DebugKit provides a debugging toolbar and enhanced debugging tools for CakePHP applications.
The master branch has the following requirements:
Ensure require is present in composer.json. This will install the plugin into Plugin/DebugKit:
{
"require": {
"cakephp/debug_kit": "2.2.*"
}
}
If you have an issues with DebugKit please open a ticket on lighthouse http://cakephp.lighthouseapp.com/projects/42880-debug-kit/overview
If you'd like to contribute to DebugKit, check out the Roadmap for any planned features. You can fork the project add features and send pull requests, or open tickets on lighthouse.
DebugKit has several releases, they are compatible with different release of CakePHP. Downloading a tag, or checking out the correct branch.
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.
There are several built-in panels. They are
The toolbar has a few configuration settings. Settings are passed in the component declaration like normal component configuration.
public $components = array( 'DebugKit.Toolbar' => array(/* array of settings */) );
You can customize the toolbar to show your custom panels or hide any built-in panel when adding it toolbar to your components.
public $components = array('DebugKit.Toolbar' => array(
'panels' => array('customPanel', 'timer'=>false)
)
);
Would display your custom panel and all built-in panels except the 'Timer' panel.
Using the panels key you can specify which panels you want to load, as well as the order in which you want the panels loaded.
public $components = array(
'DebugKit.Toolbar' => array('panels' => array('myCustomPanel', 'timer' => false))
);
Would add your custom panel myCustomPanel to the toolbar and exclude the default Timer panel. In addition to choosing which panels you want, you can pass options into the __construct of the panels. For example the built-in History panel uses the history key to set the number of historical requests to track.
public $components = array(
'DebugKit.Toolbar' => array('history' => 10)
);
Would load the History panel and set its history level to 10. The panels key is not passed to the Panel constructor.
The forceEnable setting is new in DebugKit 1.1. It allows you to force the toolbar to display regardless of the value of Configure::read('debug');. This is useful when profiling an application with debug kit as you can enable the toolbar even when running the application in production mode.
autoRun is a new configuration setting for DebugKit 1.2. It allows you to control whether or not the toolbar is displayed automatically or whether you would like to use a query string parameter to enable it. Set this configuration key to false to use query string parameter toggling of the toolbar.
var $components = array(
'DebugKit.Toolbar' => array('autoRun' => false)
);
When visiting a page you can add ?debug=true to the url and the toolbar will be visible. Otherwise it will stay hidden and not execute.
You can create your own custom panels for DebugKit to help in debugging your applications.
Panel Classes simply need to be placed inPanel directory inside a Lib path. The filename should match the classname, so the class MyCustomPanel would be expected to have a filename of app/Lib/Panel/MyCustomPanel.php.
class MyCustomPanel extends DebugPanel {
...
}
Notice that custom panels are required to subclass the DebugPanel class. Panels can define the css and javascript properties to include additional CSS or javascript on the page. Both properties should be an array.
class MyCustomPanel extends DebugPanel {
public $javascript = array(
'/my_plugin/js/custom_panel.js'
);
}
Panel objects have 2 callbacks, that allow them to hook into and introspect on the current request.
startup(Controller $controller)
Each panel's startup() method is called during component startup() process. $controller is a reference to the current controller object.
beforeRender(Controller $controller)
Much like startup() beforeRender() is called 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.
/**
* beforeRender callback - grabs request params
*
* @return array
*/
function beforeRender(Controller $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
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 sqllog_panel.ctp. These elements should be located in the root of your View/Elements directory.
Panels should pick up their title and element name by convention. However, if you need to choose a custom element name or title, there are properties to allow that configuration.
Panels provided by Cake Plugins work almost entirely the same as other plugins, with one minor difference: You must set var $plugin to be the name of the plugin directory, so that the panel's Elements can be located at render time.
class MyCustomPanel extends DebugPanel {
var $plugin = 'MyPlugin';
...
}
To use a plugin panel, use the common CakePHP dot notation for plugins.
public $components = array('DebugKit.Toolbar' => array(
'panels' => array('MyPlugin.MyCustom')
));
The above would load all the default panels as well as the custom panel from MyPlugin.
By default DebugKit uses File as engine for internal cache, but if you want to use another cache engine you can customize it simply adding an cache key inside the components config array.
public $components = array('DebugKit.Toolbar' => array(
'cache' => array('engine' => 'Memcache', 'servers' => array('127.0.0.1:11211'))
)
);
You can use any cache engine supported by CakePHP, the same you set in both core.php and bootstrap.php files with Cache::config() method.
| Back | FazBrowse Home | New Git URL |