You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-1Lines changed: 46 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,4 +22,49 @@ Requirements:
22
22
23
23
## Usage
24
24
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