|
1 | 1 | # Micro Framework - The minimum kernel for application initialization. |
2 | 2 |
|
3 | | -### Requirements |
4 | | - |
5 | | -PHP >= 8.0.0 |
6 | | - |
7 | | -### How to use the library |
8 | | - |
9 | | -Add the latest version of micro/kernel 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 | | -use Micro\Framework\Kernel\Configuration\DefaultApplicationConfiguration; |
32 | | -use Micro\Framework\Kernel\Plugin\PluginDependedInterface; |
33 | | -use Micro\Framework\Kernel\Plugin\ApplicationPluginInterface; |
34 | | -use Micro\Component\DependencyInjection\Container; |
35 | | -use Micro\Framework\Kernel\Plugin\PluginBootLoaderInterface; |
36 | | -use Micro\Framework\Kernel\KernelBuilder; |
37 | | - |
38 | | -// Create simple plugin |
39 | | -class TestPlugin implements PluginDependedInterface |
40 | | -{ |
41 | | - public function provideDependencies(Container $container): void |
42 | | - { |
43 | | - print_r('Provided dependencies'); |
44 | | - } |
45 | | -} |
46 | | - |
47 | | -// Create Dependency provider boot loader |
48 | | -class DependencyProviderLoader implements PluginBootLoaderInterface |
49 | | -{ |
50 | | - |
51 | | - public function __construct(private readonly Container $container) |
52 | | - { |
53 | | - } |
54 | | - |
55 | | - public function boot(ApplicationPluginInterface $applicationPlugin): void |
56 | | - { |
57 | | - $applicationPlugin->getDependedPlugins($this->container); |
58 | | - } |
59 | | -} |
60 | | - |
61 | | -$kernelBuilder = new KernelBuilder(); |
62 | | -$container = new Container(); |
63 | | -$configuration = new DefaultApplicationConfiguration(['APP_ENV' => 'dev']); |
64 | | -$kernel = $kernelBuilder |
65 | | - ->setApplicationConfiguration($configuration) |
66 | | - ->setContainer($container) |
67 | | - ->setApplicationPlugins([ |
68 | | - TestPlugin::class |
69 | | - ]) |
70 | | - ->addBootLoaders([ |
71 | | - new DependencyProviderLoader($container) |
72 | | - ]) |
73 | | - ->build(); |
74 | | -; |
75 | | - |
76 | | -$kernel->run(); |
77 | | -``` |
78 | | - |
79 | | -## License |
80 | | - |
81 | | -[MIT](LICENSE) |
| 3 | +Documentation is available [here](https://micro-php.net/docs). If not, we will be grateful if you can become its author :) |
0 commit comments