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
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,18 @@ $kernel = new Kernel([
34
34
$container = $kernel->createContainer();
35
35
```
36
36
37
+
If you want to register configuration on the container, you can:
38
+
39
+
- create a module - this is the recommended solution, read the next sections to learn more
40
+
- or set the configuration directly - this is useful in micro-frameworks or micro-applications:
41
+
42
+
```php
43
+
$kernel = new Kernel();
44
+
$kernel->addConfig([
45
+
'db.host' => 'localhost',
46
+
]);
47
+
```
48
+
37
49
### Installing a module
38
50
39
51
To install a 3rd party module:
@@ -49,9 +61,9 @@ To install a 3rd party module:
49
61
50
62
### Creating a module
51
63
52
-
1. choose a module name, for example `blogpress`
64
+
1. choose a module name, usually `app` when writing an application, or anything else when writing a reusable module
53
65
1. create a resource directory in your package, usually `res/`
54
-
1. map it with Puli, for example `puli map /blogpress res`
66
+
1. map it with Puli, for example `puli map /app res`
55
67
1. create as many PHP-DI configuration files as needed in `res/config/`
56
68
57
69
That's it. Here is what your package should look like:
@@ -67,7 +79,15 @@ composer.json
67
79
puli.json
68
80
```
69
81
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).
82
+
When the module is registered in the kernel like this:
83
+
84
+
```php
85
+
$kernel = new Kernel([
86
+
'app',
87
+
]);
88
+
```
89
+
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.
0 commit comments