@@ -21,24 +21,50 @@ Plugin::load('CakeDC/Api', ['bootstrap' => true, 'routes' => true]);
21
21
22
22
## Configuration
23
23
You can configure the api overwriting the api.php, how?
24
- we need to create an ** api.php** file in the * config* folder. You can copy the existing configuration file
24
+ we need to create an ** api.php** file in the * config* folder. You can copy the existing configuration file
25
25
under ` vendor/cakedc/cakephp-api/config/api.php ` and customize it for your application.
26
26
Remember to load the new configuration file in ` bootstrap.php `
27
27
28
28
``` php
29
29
Plugin::load('CakeDC/Api', ['bootstrap' => false, 'routes' => true]);
30
30
Configure::load('api');
31
- ```
31
+ ```
32
+
33
+ CakePHP 4.x configuration loading form Application class:
34
+
35
+ ``` php
36
+ Configure::write('Api.config', ['api']);
37
+ $this->addPlugin('CakeDC/Api', ['bootstrap' => true, 'routes' => true]);
38
+ ```
39
+ In this case plugin will load default configuration file from CakeDC/Api/config/api.php
40
+ and after that append the configuration from ./config/api.php
41
+
42
+ If needed to overwrite one of sections in the default confugration file it is possible to pass
43
+ config names as key and merge param as value of ` Api.config ` settings.
44
+
45
+ Example, if we want merge api.php and overwrite specific node like Api.Middleware we can create addtional configuration file config/api_mw.php
46
+ ``` php
47
+ return [
48
+ 'Api.Middleware' => [
49
+ // ... overwrite section here
50
+ ]
51
+ ];
52
+ ```
53
+ And in Application.php we will have
54
+ ``` php
55
+ Configure::write('Api.config', ['api' => true, 'api_mw' => false]);
56
+ $this->addPlugin('CakeDC/Api', ['bootstrap' => true, 'routes' => true]);
57
+ ```
32
58
33
59
## OPTIONAL: User Plugin
34
60
35
- We rely on CakeDC/Users plugin for Auth, in case you need to define Auth for your API,
61
+ We rely on CakeDC/Users plugin for Auth, in case you need to define Auth for your API,
36
62
ensure * CakeDC/Users* plugin is installed and loaded from your ` bootstrap.php ` .
37
63
38
64
### Configuration and Loading
39
65
40
66
```
41
67
Configure::write('Users.config', ['users']);
42
68
Plugin::load('CakeDC/Users', ['bootstrap' => false, 'routes' => true]);
43
- ```
69
+ ```
44
70
Check more details about how CakeDC/Users plugin could be configured here: https://github.com/CakeDC/users/blob/master/Docs/Documentation/Configuration.md
0 commit comments