-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.php
More file actions
59 lines (50 loc) · 2.07 KB
/
module.php
File metadata and controls
59 lines (50 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
use Marko\Config\ConfigRepositoryInterface;
use Marko\Core\Container\ContainerInterface;
use Marko\Core\Path\ProjectPaths;
use Marko\Debugbar\Debugbar;
use Marko\Debugbar\Plugins\DatabaseConnectionPlugin;
use Marko\Debugbar\Plugins\LoggerPlugin;
use Marko\Debugbar\Plugins\ViewPlugin;
use Marko\Debugbar\Storage\DebugbarStorage;
return [
'enabled' => true,
'sequence' => [
'after' => ['marko/config', 'marko/routing'],
],
'bindings' => [
DebugbarStorage::class => static function (ContainerInterface $container): DebugbarStorage {
$config = $container->get(ConfigRepositoryInterface::class);
$paths = $container->get(ProjectPaths::class);
if (! $config instanceof ConfigRepositoryInterface) {
throw new RuntimeException('Config repository binding must implement '.ConfigRepositoryInterface::class);
}
if (! $paths instanceof ProjectPaths) {
throw new RuntimeException('Project paths binding must be '.ProjectPaths::class);
}
return new DebugbarStorage($config, $paths);
},
Debugbar::class => static function (ContainerInterface $container): Debugbar {
$config = $container->get(ConfigRepositoryInterface::class);
$storage = $container->get(DebugbarStorage::class);
if (! $config instanceof ConfigRepositoryInterface) {
throw new RuntimeException('Config repository binding must implement '.ConfigRepositoryInterface::class);
}
if (! $storage instanceof DebugbarStorage) {
throw new RuntimeException('Debugbar storage binding must be '.DebugbarStorage::class);
}
return new Debugbar($config, $storage);
},
],
'singletons' => [
Debugbar::class,
DebugbarStorage::class,
DatabaseConnectionPlugin::class,
LoggerPlugin::class,
ViewPlugin::class,
],
'boot' => static function (Debugbar $debugbar): void {
$debugbar->boot();
},
];