11# PHP-DI application kernel
22
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 ) .
44
55[ ![ Build Status] ( https://img.shields.io/travis/PHP-DI/Kernel.svg?style=flat-square )] ( https://travis-ci.org/PHP-DI/Kernel )
66[ ![ Coverage Status] ( https://img.shields.io/coveralls/PHP-DI/Kernel/master.svg?style=flat-square )] ( https://coveralls.io/r/PHP-DI/Kernel?branch=master )
77
88## Introduction
99
10- TODO
10+ The Kernel let's you build an application based on PHP-DI modules.
1111
1212## Installation
1313
1414```
1515composer require php-di/kernel
1616```
1717
18- Requirements:
19-
20- - PHP 5.5 or greater
21- - [ Puli CLI tool] ( http://docs.puli.io/en/latest/installation.html#installing-the-puli-cli )
22-
2318## Usage
2419
2520The 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:
2621
2722``` php
2823$kernel = new Kernel([
29- 'twig',
30- 'doctrine',
31- 'app',
24+ 'twig/twig ',
25+ 'doctrine/dbal ',
26+ 'vendor/ app',
3227]);
3328
3429$container = $kernel->createContainer();
@@ -55,15 +50,14 @@ To install a 3rd party module:
5550
5651 ```php
5752 $kernel = new Kernel([
58- 'twig',
53+ 'twig/twig ',
5954 ]);
6055 ```
6156
6257### Creating a module
6358
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
65601. create a resource directory in your package, usually `res/`
66- 1. map it with Puli, for example `puli map /app res`
67611. create as many PHP-DI configuration files as needed in `res/config/`
6862
6963That's it. Here is what your package should look like:
7670src/
7771 ...
7872composer.json
79- puli.json
8073```
8174
8275When the module is registered in the kernel like this:
8376
8477```php
8578$kernel = new Kernel([
86- 'app ',
79+ 'foo/bar ',
8780]);
8881```
8982
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.
9184
9285### Environments
9386
0 commit comments