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
This directory is a storage for project data files and service caches.
58
+
This folder is a storage for project data files and service caches.
70
59
It contains these folders:
71
60
72
61
*`cache`: cache for e.g. Twig files
73
62
*`doctrine`: database migrations and fixtures
74
63
*`oauth`: encryption, private and public keys needed for authentication
75
64
*`data/lock` - lock files generated by [`dotkernel/dot-cli`](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
76
65
77
-
> AVOID storing sensitive data on VCS.
66
+
> AVOID storing sensitive data on the repository!
78
67
79
-
###`log`directory
68
+
## `log`folder
80
69
81
-
This directory stores daily log files.
70
+
This folder stores daily log files.
82
71
When you access the application from the browser, (if not already created) a new log file gets created in the format specified in the `config/autoload/error-handling.global.php` config file under the `stream` array key.
83
72
84
-
###`public`directory
73
+
## `public`folder
85
74
86
-
This directory contains all publicly available assets and serves as the entry point of the application:
75
+
This folder contains all publicly available assets and serves as the entry point of the application:
87
76
88
77
*`uploads`: a folder that normally contains files uploaded via the application
89
78
*`.htaccess`: server configuration file used by Apache web server; it enables the URL rewrite functionality
90
79
*`index.php`: the application's main entry point
91
80
*`robots.txt.dist`: a sample robots.txt file that allows/denies bot access to certain areas of your application; activate it by duplicating the file as `robots.txt` and comment out the lines that don't match your environment
92
81
93
-
## `src`directory
82
+
## `src`folder
94
83
95
84
This folder contains a separate folder for each Module.
96
-
Each Module folder, in turn, should contain following directories, unless they are empty:
97
85
98
-
* Handler - Action classes (similar to Controllers but can only perform one action)
99
-
* Entity - Used by database entities
100
-
* Service - Service classes
101
-
* Collection - Database entities collections
102
-
* Repository - Entity repository folder
86
+
These are the modules included by default:
87
+
88
+
*`Admin` - contains functionality for managing users with `admin` role; note these are users save in the `admin` database table
89
+
*`App` - contains core functionality, from authentication, to rendering, to error reporting
90
+
*`User` - contains functionality for managing regular users
91
+
92
+
### Module contents
93
+
94
+
Each Module folder, in turn, should contain the following folders, unless they are empty:
103
95
104
-
> The above example is just some of the directories a project may include, but they should give you an idea about the recommended structure.
96
+
*`src/Handler` - Action classes (similar to Controllers but can only perform one action)
97
+
*`src/Entity` - Used by database entities
98
+
*`src/Service` - Service classes
99
+
*`src/Collection` - Database entities collections
100
+
*`src/Repository` - Entity repository folder
105
101
106
-
Other classes in the `src` directory may include `InputFilter`, `EventListener`, `Helper`, `Command`, `Factory` etc.
102
+
The above example is just some of the folders a project may include, but they should give you an idea about the recommended structure.
103
+
Other classes the `src` folder may include are `InputFilter`, `EventListener`, `Helper`, `Command`, `Factory` etc.
107
104
108
-
The `src`directory normally also contains these files:
105
+
The `src`folder in each Module folder normally also contains these files:
109
106
110
107
*`ConfigProvider.php` - Configuration data for the module
111
108
*`OpenAPI.php` - Detailed descriptions for each endpoint in the OpenAPI format
112
-
*`RoutesDelegator.php` - Module specific route registrations Module main routes entry file
109
+
*`RoutesDelegator.php` - Module specific route registrations
113
110
114
-
## `templates`directory
111
+
###`templates`folder in Modules
115
112
116
-
This directory contains the template files, used for example to help render e-mail templates.
113
+
This folder contains the template files, used for example to help render e-mail templates.
117
114
118
-
> Dotkernel API uses twig as Templating Engine. All template files have the extension .html.twig
115
+
> Dotkernel API uses twig as Templating Engine. All template files have the extension `.html.twig`
Based on Enrico Zimuel’s Zend Expressive API – Skeleton example, Dotkernel API runs on Laminas and Mezzio components and implements standards like PSR-3, PSR-4, PSR-7, PSR-11 and PSR-15.
Below is a quick overview of features in Dotkernel API.
26
4
27
5
## Doctrine 3 ORM
28
6
@@ -40,7 +18,7 @@ We use the following files in which we store information about every available e
40
18
41
19
## Hypertext Application Language
42
20
43
-
For our API payloads (a value object for describing the API resource, its relational links and any embedded/child resources related to it) we chose mezzio-hal.
21
+
For our API payloads (a value object for describing the API resource, its relational links and any embedded/child resources related to it) we use [mezzio/mezzio-hal](https://github.com/mezzio/mezzio-hal).
44
22
45
23
## CORS
46
24
@@ -51,23 +29,23 @@ Therefore, for every preflight request, there is at least one Router request.
51
29
## OAuth 2.0
52
30
53
31
OAuth 2.0 is an authorization framework that enables applications to obtain limited access to user accounts on your Dotkernel API.
54
-
We are using mezzio/mezzio-authentication-oauth2 which provides OAuth 2.0 authentication for Mezzio and PSR-7/PSR-15 applications by using league/oauth2-server package.
32
+
We use [mezzio/mezzio-authentication-oauth2](https://github.com/mezzio/mezzio-authentication-oauth2) which provides OAuth 2.0 authentication for Mezzio and PSR-7/PSR-15 applications by using the [thephpleague/oauth2-server]https://github.com/thephpleague/oauth2-server package.
55
33
56
34
## Email
57
35
58
36
It is not unlikely for an API to send emails depending on the use case.
59
37
Here is another area where Dotkernel API shines.
60
-
Using `DotMailServiceMailService` provided by dotkernel/dot-mail you can easily send custom email templates.
38
+
Using `DotMailServiceMailService` provided by [dotkernel/dot-mail](https://github.com/dotkernel/dot-mail) you can easily send custom email templates.
61
39
62
40
## Configuration
63
41
64
-
From authorization at request route level to API keys for your application, you can find every configuration variable in the config directory.
42
+
From authorization at request route level to API keys for your application, you can find every configuration variable in the `config` directory.
65
43
66
-
Registering a new module can be done by including its ConfigProvider.php in config.php.
44
+
Registering a new module can be done by including its `ConfigProvider.php` in `config.php`.
67
45
68
-
Brand new middlewares should go into pipeline.php. Here you can edit the order in which they run and find more info about the currently included ones.
46
+
Brand new middlewares should go into `pipeline.php`. Here you can edit the order in which they run and find more info about the currently included ones.
69
47
70
-
You can further customize your api within the autoload directory where each configuration category has its own file.
48
+
You can further customize your api within the `autoload` directory that holds configuration files for each category.
71
49
72
50
## Routing
73
51
@@ -83,37 +61,25 @@ Then you can enable it by registering it in `config/autoload/cli.global.php`.
83
61
84
62
## File locker
85
63
86
-
Here you will also find our brand-new file locker configuration, so you can easily turn it on or off (by default: `'enabled' => true`).
64
+
Here you will also find our file locker configuration, so you can easily enable and disable it (by default: `'enabled' => true`).
87
65
88
66
Note: The File Locker System will create a `command-{command-default-name}.lock` file which will not let another instance of the same command to run until the previous one has finished.
89
67
90
-
## PSR Standards
91
-
92
-
*[PSR-3](https://www.php-fig.org/psr/psr-3/): Logger Interface – the application uses `LoggerInterface` for error logging
93
-
*[PSR-4](https://www.php-fig.org/psr/psr-4): Autoloader – the application locates classes using an autoloader
94
-
*[PSR-7](https://www.php-fig.org/psr/psr-7): HTTP message interfaces – the handlers return `ResponseInterface`
95
-
*[PSR-11](https://www.php-fig.org/psr/psr-11): Container interface – the application is container-based
96
-
*[PSR-15](https://www.php-fig.org/psr/psr-15): HTTP Server Request Handlers – the handlers implement `RequestHandlerInterface`
97
-
98
68
## Tests
99
69
100
70
One of the best ways to ensure the quality of your product is to create and run functional and unit tests.
101
-
You can find factory-made tests in the `tests/AppTest/` folder, and you can also register your own.
71
+
You can find factory-made tests in the `test` folder, and you can also register your own.
102
72
103
-
We have 2 types of tests: functional and unit tests, you can run both types at the same type by executing this command:
73
+
We have 2 types of tests: functional and unit tests.
74
+
You can run both types at the same type by executing this command:
104
75
105
76
```shell
106
77
php vendor/bin/phpunit
107
78
```
108
79
109
-
## Running unit tests
80
+
Alternatively, you can run each test category separately with these commands:
0 commit comments