File tree Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ > ** :heavy_exclamation_mark : Basic container implementation with the ability to inject dependencies**
2
+
3
+ ### Requirements
4
+
5
+ PHP >= 8.0.0
6
+
7
+ ### How to use the library
8
+
9
+ Add the latest version of MicroDependencyInjection into your project by using Composer or manually:
10
+
11
+ __ Using Composer (Recommended)__
12
+
13
+ Or require the package inside the composer.json of your project:
14
+ ```
15
+ "require": {
16
+ "micro/kernel": "^1"
17
+ },
18
+ ```
19
+
20
+ ### Example
21
+
22
+ After adding the library to your project, include the file autoload.php found in root of the library.
23
+ ``` html
24
+ include 'vendor/autoload.php';
25
+ ```
26
+
27
+ #### Simple usage:
28
+
29
+ ``` php
30
+
31
+ // Create simple plugin
32
+ class TestPlugin extends \Micro\Framework\Kernel\Plugin\AbstractPlugin
33
+ {
34
+ public function provideDependencies(\Micro\Component\DependencyInjection\Container $container): void
35
+ {
36
+ print_r('Provided dependencies');
37
+ }
38
+ }
39
+
40
+ // Create Dependency provider boot loader
41
+ class DependencyProviderLoader implements \Micro\Framework\Kernel\Plugin\PluginBootLoaderInterface
42
+ {
43
+
44
+ public function __construct(private readonly \Micro\Component\DependencyInjection\Container $container)
45
+ {
46
+ }
47
+
48
+ public function boot(\Micro\Framework\Kernel\Plugin\ApplicationPluginInterface $applicationPlugin): void
49
+ {
50
+ $applicationPlugin->provideDependencies($this->container);
51
+ }
52
+ }
53
+
54
+ $kernelBuilder = new \Micro\Framework\Kernel\KernelBuilder();
55
+ $container = new \Micro\Component\DependencyInjection\Container();
56
+ $configuration = new \Micro\Framework\Kernel\Configuration\DefaultApplicationConfiguration(['APP_ENV' => 'dev']);
57
+ $kernel = $kernelBuilder
58
+ ->setApplicationConfiguration($configuration)
59
+ ->setContainer($container)
60
+ ->setApplicationPlugins([
61
+ TestPlugin::class
62
+ ])
63
+ ->setBootLoaders([
64
+ new DependencyProviderLoader($container)
65
+ ])
66
+ ->build();
67
+ ;
68
+
69
+ $kernel->run();
70
+ ```
71
+
72
+ ## License
73
+
74
+ [ MIT] ( LICENSE )
You can’t perform that action at this time.
0 commit comments