Skip to content

Commit 5562d70

Browse files
committed
Add documentation
1 parent 0f7fc8f commit 5562d70

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,49 @@ Requirements:
2222

2323
## Usage
2424

25-
TODO
25+
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+
27+
```php
28+
$kernel = new Kernel([
29+
'twig',
30+
'doctrine',
31+
'app',
32+
]);
33+
34+
$container = $kernel->createContainer();
35+
```
36+
37+
### Installing a module
38+
39+
To install a 3rd party module:
40+
41+
- install the package using Composer
42+
- add it to the list of modules your kernel will load, for example:
43+
44+
```php
45+
$kernel = new Kernel([
46+
'twig',
47+
]);
48+
```
49+
50+
### Creating a module
51+
52+
1. choose a module name, for example `blogpress`
53+
1. create a resource directory in your package, usually `res/`
54+
1. map it with Puli, for example `puli map /blogpress res`
55+
1. create as many PHP-DI configuration files as needed in `res/config/`
56+
57+
That's it. Here is what your package should look like:
58+
59+
```
60+
res/
61+
config/
62+
config.php
63+
...
64+
src/
65+
...
66+
composer.json
67+
puli.json
68+
```
69+
70+
When users install your package and tell the kernel to load the `blogpress` module, it will load all the files matching the Puli path `/blogpress/config/*.php` (i.e. `vendor/johndoe/blogpress/res/config/*.php` on the filesystem).

0 commit comments

Comments
 (0)