1
1
# PHP-DI application kernel
2
2
3
- Kernel for applications built with [ PHP-DI] ( http://php-di.org ) and [ Puli ] ( http ://puli.io ) with built-in support for PHP-DI modules .
3
+ Kernel for building modules with [ PHP-DI] ( http://php-di.org ) and [ Composer-Locator ] ( https ://github.com/mindplay-dk/composer-locator ) .
4
4
5
5
[ ![ Build Status] ( https://img.shields.io/travis/PHP-DI/Kernel.svg?style=flat-square )] ( https://travis-ci.org/PHP-DI/Kernel )
6
6
[ ![ Coverage Status] ( https://img.shields.io/coveralls/PHP-DI/Kernel/master.svg?style=flat-square )] ( https://coveralls.io/r/PHP-DI/Kernel?branch=master )
7
7
8
8
## Introduction
9
9
10
- TODO
10
+ The Kernel let's you build an application based on PHP-DI modules.
11
11
12
12
## Installation
13
13
14
14
```
15
15
composer require php-di/kernel
16
16
```
17
17
18
- Requirements:
19
-
20
- - PHP 7.0 or greater
21
- - [ Puli CLI tool] ( http://docs.puli.io/en/latest/installation.html#installing-the-puli-cli )
22
-
23
18
## Usage
24
19
25
20
The kernel's role is to create the container. It does so by registering all the configuration files of the modules we ask it to load:
26
21
27
22
``` php
28
23
$kernel = new Kernel([
29
- 'twig',
30
- 'doctrine',
31
- 'app',
24
+ 'twig/twig ',
25
+ 'doctrine/dbal ',
26
+ 'vendor/ app',
32
27
]);
33
28
34
29
$container = $kernel->createContainer();
@@ -55,15 +50,14 @@ To install a 3rd party module:
55
50
56
51
```php
57
52
$kernel = new Kernel([
58
- 'twig',
53
+ 'twig/twig ',
59
54
]);
60
55
```
61
56
62
57
### Creating a module
63
58
64
- 1. choose a module name, usually `app` when writing an application, or anything else when writing a reusable module
59
+ 1. the Composer package name is the module name
65
60
1. create a resource directory in your package, usually `res/`
66
- 1. map it with Puli, for example `puli map /app res`
67
61
1. create as many PHP-DI configuration files as needed in `res/config/`
68
62
69
63
That's it. Here is what your package should look like:
76
70
src/
77
71
...
78
72
composer.json
79
- puli.json
80
73
```
81
74
82
75
When the module is registered in the kernel like this:
83
76
84
77
```php
85
78
$kernel = new Kernel([
86
- 'app ',
79
+ 'foo/bar ',
87
80
]);
88
81
```
89
82
90
- all the files matching the Puli path ` /blogpress/config/*.php ` (i.e. ` vendor/johndoe/blogpress /res/config/*.php ` on the filesystem) will be loaded.
83
+ all the files in ` vendor/foo/bar /res/config/*.php ` will be loaded.
91
84
92
85
### Environments
93
86
0 commit comments