diff --git a/demo/bootstrap.php b/demo/bootstrap.php index 0a7bb3b..21bdb42 100644 --- a/demo/bootstrap.php +++ b/demo/bootstrap.php @@ -7,8 +7,11 @@ use DebugBar\StandardDebugBar; $debugbar = new StandardDebugBar(); $debugbarRenderer = $debugbar->getJavascriptRenderer()->setBaseUrl('../src/DebugBar/Resources'); -$debugbar->setStorage(new DebugBar\Storage\FileStorage(__DIR__ . '/profiles')); -$debugbarRenderer->setOpenHandlerUrl('open.php'); +// +// create a writable profiles folder in the demo directory to uncomment the following lines +// +//$debugbar->setStorage(new DebugBar\Storage\FileStorage(__DIR__ . '/profiles')); +//$debugbarRenderer->setOpenHandlerUrl('open.php'); function render_demo_page(Closure $callback = null) { diff --git a/docs/javascript_bar.md b/docs/javascript_bar.md index 1a44db0..be4f251 100644 --- a/docs/javascript_bar.md +++ b/docs/javascript_bar.md @@ -1,5 +1,8 @@ # Javascript Bar +**This section is here to document the inner workings of the client side debug bar. +Nothing described below is needed to run the debug bar in a normal way.** + The default client side implementation of the debug bar is made entirely in Javascript and is located in the *debugbar.js* file. @@ -165,3 +168,14 @@ and indicators of type `PhpDebugBar.DebugBar.Indicator`. These classes subclass // ---- debugbar.addIndicator('phpdoc', new LinkIndicator({ href: 'http://doc.php.com', title: 'PHP doc' })); + +## OpenHandler + +An OpenHandler object can be provided using `setOpenHandler()`. The object is in charge +of loading datasets. The only requirement is to provide a `show()` method which takes +as only parameter a callback which expects an id and data parameter. + +The default implementation is `PhpDebugBar.OpenHandler` which must be use in conjonction +with the server side `DebugBar\OpenHandler` (see previous section). + + debugbar.setOpenHandler(new PhpDebugBar.OpenHandler({ url: "open.php" })); \ No newline at end of file diff --git a/docs/manifest.json b/docs/manifest.json index eede10f..d3f2a34 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -9,6 +9,7 @@ "base_collectors.md", "bridge_collectors.md", "storage.md", + "openhandler.md", "javascript_bar.md" ] } diff --git a/docs/openhandler.md b/docs/openhandler.md new file mode 100644 index 0000000..180ce91 --- /dev/null +++ b/docs/openhandler.md @@ -0,0 +1,23 @@ +# Open handler + +The debug bar can open previous sets of collected data which were stored using +a storage handler (see previous section). To do so, it needs to be provided an +url to an open handler. + +An open handler must respect a very simple protocol. The default implementation +is `DebugBar\OpenHandler`. + + $openHandler = new DebugBar\OpenHandler($debugbar); + $openHandler->handle(); + +Calling `handle()` will use data from the `$_REQUEST` array and echo the output. +The function also supports input from other source if you provide an array as +first argument. It can also return the data instead of echoing (use false as +second argument) and not send the content-type header (use false as third argument). + +One you have setup your open handler, tell the `JavascriptRenderer` its url. + + $renderer->setOpenHandlerUrl('open.php'); + +This adds a button in the top right corner of the debug bar which allows you +to browse and open previous sets of collected data. \ No newline at end of file