Skip to content

Commit 38d2c89

Browse files
authored
Merge pull request #76 from dotkernel/versions
Versions
2 parents 6e05cba + 3b79ed7 commit 38d2c89

File tree

2 files changed

+51
-88
lines changed

2 files changed

+51
-88
lines changed

docs/book/v5/introduction/file-structure.md

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,22 @@ When using Dotkernel API the following structure is installed by default:
88

99
![Dotkernel API File Structure!](https://docs.dotkernel.org/img/api/file-structure-dk-api.png)
1010

11-
## Main directories
12-
13-
* `bin` - executable files from CLI
14-
* `config` - various configuration files
15-
* `data` - should contain project-related data (AVOID storing sensitive data on VCS)
16-
* `documentation` - should contain project-related documentation
17-
* `log` - storage of log files generated by dot-error-log library
18-
* `public` - publicly visible files. The webserver need to have this folder as www-document root folder.
19-
* `src` - should contain the source code files
20-
* `test` - should contain the test files
21-
2211
## Special purpose folders
2312

24-
* `.github` - containes workflow files
13+
* `.github` - contains GitHub workflow files
2514
* `.laminas-ci` - contains laminas-ci workflow files
2615

27-
### `bin` directory
16+
## `bin` folder
2817

29-
This directory contents are
18+
This folder contents are
3019

31-
* `clear-config-cache.php` which removes the config cache file (`data/cache/config-cache.php` - available only when development mode is enabled).
20+
* `clear-config-cache.php` - removes the config cache file (`data/cache/config-cache.php` - available only when development mode is enabled).
3221
* `cli.php` used to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli)
33-
* `doctrine` used by the doctrine fixtures to populate the database tables
22+
* `doctrine` - used by the doctrine fixtures to populate the database tables
3423

35-
### `config` directory
24+
## `config` folder
3625

37-
This directory contains all application-related config files:
26+
This folder contains all application-related config files:
3827

3928
* `cli-config.php`: command line interface configuration used by migrations, fixtures, crons
4029
* `config.php`: registers ConfigProviders for installing packages
@@ -44,9 +33,9 @@ This directory contains all application-related config files:
4433
* `pipeline.php`: contains a list of middlewares, in the order of their execution
4534
* `twig-cs-fixer.php`: configuration file for Twig code style checker/fixer
4635

47-
#### `config/autoload` directory
36+
### `config/autoload` folder
4837

49-
This directory contains all service-related local and global config files:
38+
This folder contains all service-related local and global config files:
5039

5140
* `authorization.global.php`: configures access per route for user roles
5241
* `cli.global.php`: configures cli
@@ -64,55 +53,63 @@ This directory contains all service-related local and global config files:
6453
* `response-header.global.php`: defines headers per route
6554
* `templates.global.php`: dotkernel/dot-twigrenderer config file
6655

67-
### `data` directory
56+
## `data` folder
6857

69-
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.
7059
It contains these folders:
7160

7261
* `cache`: cache for e.g. Twig files
7362
* `doctrine`: database migrations and fixtures
7463
* `oauth`: encryption, private and public keys needed for authentication
7564
* `data/lock` - lock files generated by [`dotkernel/dot-cli`](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
7665

77-
> AVOID storing sensitive data on VCS.
66+
> AVOID storing sensitive data on the repository!
7867
79-
### `log` directory
68+
## `log` folder
8069

81-
This directory stores daily log files.
70+
This folder stores daily log files.
8271
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.
8372

84-
### `public` directory
73+
## `public` folder
8574

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:
8776

8877
* `uploads`: a folder that normally contains files uploaded via the application
8978
* `.htaccess`: server configuration file used by Apache web server; it enables the URL rewrite functionality
9079
* `index.php`: the application's main entry point
9180
* `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
9281

93-
## `src` directory
82+
## `src` folder
9483

9584
This folder contains a separate folder for each Module.
96-
Each Module folder, in turn, should contain following directories, unless they are empty:
9785

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:
10395

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
105101

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.
107104

108-
The `src` directory normally also contains these files:
105+
The `src` folder in each Module folder normally also contains these files:
109106

110107
* `ConfigProvider.php` - Configuration data for the module
111108
* `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
113110

114-
## `templates` directory
111+
### `templates` folder in Modules
115112

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.
117114

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`
Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
# Introduction
22

3-
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.
4-
5-
Here is a list of the core components:
6-
7-
* Middleware Microframework (mezzio/mezzio)
8-
* Error Handler (dotkernel/dot-errorhandler)
9-
* Problem Details (mezzio/mezzio-problem-details)
10-
* CORS (mezzio/mezzio-cors)
11-
* Routing (mezzio/mezzio-fastroute)
12-
* Authentication (mezzio/mezzio-authentication)
13-
* Authorization (mezzio/mezzio-authorization)
14-
* Config Aggregator (laminas/laminas-config-aggregator)
15-
* Container (roave/psr-container-doctrine)
16-
* Dependency Injection (dotkernel/dot-dependency-injection)
17-
* Input Filter (laminas/laminas-inputfilter)
18-
* Doctrine 3 ORM (doctrine/orm)
19-
* Serializer/Deserializer (laminas/laminas-hydrator)
20-
* Paginator (laminas/laminas-paginator)
21-
* HAL (mezzio/mezzio-hal)
22-
* CLI (dotkernel/dot-cli)
23-
* TwigRenderer (mezzio/mezzio-twigrenderer)
24-
* Fixtures (dotkernel/dot-data-fixtures)
25-
* UUID (ramsey/uuid-doctrine)
3+
Below is a quick overview of features in Dotkernel API.
264

275
## Doctrine 3 ORM
286

@@ -40,7 +18,7 @@ We use the following files in which we store information about every available e
4018

4119
## Hypertext Application Language
4220

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).
4422

4523
## CORS
4624

@@ -51,23 +29,23 @@ Therefore, for every preflight request, there is at least one Router request.
5129
## OAuth 2.0
5230

5331
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.
5533

5634
## Email
5735

5836
It is not unlikely for an API to send emails depending on the use case.
5937
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.
6139

6240
## Configuration
6341

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.
6543

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`.
6745

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.
6947

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.
7149

7250
## Routing
7351

@@ -83,37 +61,25 @@ Then you can enable it by registering it in `config/autoload/cli.global.php`.
8361

8462
## File locker
8563

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`).
8765

8866
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.
8967

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-
9868
## Tests
9969

10070
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.
10272

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:
10475

10576
```shell
10677
php vendor/bin/phpunit
10778
```
10879

109-
## Running unit tests
80+
Alternatively, you can run each test category separately with these commands:
11081

11182
```shell
11283
vendor/bin/phpunit --testsuite=UnitTests --testdox --colors=always
113-
```
114-
115-
## Running functional tests
116-
117-
```shell
11884
vendor/bin/phpunit --testsuite=FunctionalTests --testdox --colors=always
11985
```

0 commit comments

Comments
 (0)