Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit d6e1e97

Browse files
committed
Updated docs to use factory provided by php-debug-bar
As of 1.1.0, released yesterday, php-middleware/php-debug-bar now provides a factory for the middleware it provides. Additionally, this factory will check if the URI path matches an asset provided by the debug bar, and, if so, stream it back, eliminating the instructions required for serving the assets.
1 parent 8d16cce commit d6e1e97

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

doc/book/cookbook/debug-toolbars.md

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -59,53 +59,25 @@ First, install the middleware in your application:
5959
$ composer require php-middleware/php-debug-bar
6060
```
6161

62-
DebugBar ships with a number of fonts, CSS files, and JavaScript assets that it
63-
uses. These will need to be copied into your web root:
64-
65-
```bash
66-
$ cp -a vendor/maximebf/debugbar/src/DebugBar/Resources public/phpdebugbar
67-
```
68-
69-
(The above creates a new directory, `public/phpdebugbar/`, containing all of the
70-
assets from the DebugBar package.)
71-
72-
Next, you'll need to create a factory. As an example, you could write the
73-
following class (in `src/App/PhpDebugBarMiddlewareFactory.php`):
62+
This package provides a factory for creating the middleware, so we only need to
63+
wire it into our middleware pipeline. Create and edit the file
64+
`config/autoload/middleware-pipeline.local.php` to read as follows:
7465

7566
```php
76-
<?php
77-
namespace App;
78-
79-
use DebugBar\StandardDebugBar;
8067
use PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware;
68+
use PhpMiddleware\PhpDebugBar\PhpDebugBarMiddlewareFactory;
8169

82-
class PhpDebugBarMiddlewareFactory
83-
{
84-
public function __invoke($container)
85-
{
86-
$debugbar = new StandardDebugBar();
87-
$renderer = $debugbar->getJavascriptRenderer('/phpdebugbar');
88-
return new PhpDebugBarMiddleware($renderer);
89-
}
90-
}
91-
```
92-
93-
Finally, you will need to notify the application of this factory, and add the
94-
middleware to your middleware pipeline. Create and edit the file
95-
`config/autoload/middleware-pipeline.local.php` to read as follows:
96-
97-
```php
9870
return [
9971
'dependencies' => [
10072
'factories' => [
101-
PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware::class => App\PhpDebugBarMiddlewareFactory::class,
73+
PhpDebugBarMiddleware::class => PhpDebugBarMiddlewareFactory::class,
10274
],
10375
],
10476
'middleware_pipeline' => [
10577
'pre_routing' => [
10678
[
10779
'middleware' => [
108-
PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware::class,
80+
PhpDebugBarMiddleware::class,
10981
],
11082
],
11183
],

0 commit comments

Comments
 (0)