Skip to content

Commit 4adcaf9

Browse files
committed
updated file structure, psr pages
Signed-off-by: bidi <bidi@apidemia.com>
1 parent bd5e073 commit 4adcaf9

5 files changed

Lines changed: 99 additions & 33 deletions

File tree

docs/book/v5/core-features/content-validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Content Negotiation
22

3-
> Introduced in Dotkernel API 4.5.0
3+
> Introduced in Dotkernel API 5.0.0
44
55
**Content Negotiation** is performed by an application in order :
66

docs/book/v5/core-features/dependency-injection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Dependency Injection
22

3-
> Introduced in Dotkernel API 5.0.0
4-
53
Dependency injection is a design pattern used in software development to implement inversion of control.
64
In simpler terms, it's the act of providing dependencies for an object during instantiation.
75

86
In PHP, dependency injection can be implemented in various ways, including through constructor injection, setter injection and property injection.
97

8+
> Introduced in Dotkernel API 5.0.0
9+
1010
Dotkernel API, through its [dot-dependency-injection](https://github.com/dotkernel/dot-dependency-injection) package focuses only on constructor injection.
1111

1212
## Usage

docs/book/v5/core-features/error-reporting.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Error reporting endpoint
22

3-
> Backward incompatibility introduced in Dotkernel API 4.1.0
4-
53
The error reporting endpoint was designed to allow the **frontend developers** of your API to report any bugs they encounter in a secure way that is fully under your control.
64
To prevent unauthorized usage, the endpoint is protected by a token in the request's header.
75

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

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,95 @@ When using Dotkernel API the following structure is installed by default:
2424
* `.github` - containes workflow files
2525
* `.laminas-ci` - contains laminas-ci workflow files
2626

27+
### `bin` directory
28+
29+
This directory contents are
30+
31+
* `clear-config-cache.php` which removes the config cache file (`data/cache/config-cache.php` - available only when development mode is enabled).
32+
* `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
34+
35+
### `config` directory
36+
37+
This directory contains all application-related config files:
38+
39+
* `cli-config.php`: command line interface configuration used by migrations, fixtures, crons
40+
* `config.php`: registers ConfigProviders for installing packages
41+
* `container.php`: main service container that provides access to all registered services
42+
* `development.config.php.dist`: activates debug mode; gets symlinked as `development.config.php` when enabling development mode
43+
* `migrations.php`: configuration for database migration, like migration file location and table to save the migration log
44+
* `pipeline.php`: contains a list of middlewares, in the order of their execution
45+
* `twig-cs-fixer.php`: configuration file for Twig code style checker/fixer
46+
47+
#### `config/autoload` directory
48+
49+
This directory contains all service-related local and global config files:
50+
51+
* `authorization.global.php`: configures access per route for user roles
52+
* `cli.global.php`: configures cli
53+
* `content-negotiation.global.php`: configures request and response formats
54+
* `cors.local.php.dist`: configures Cross-Origin Resource Sharing, like call origin, headers, cookies
55+
* `dependencies.global.php`: config file to set global dependencies that should be accessible by all modules
56+
* `development.local.php.dist`: gets symlinked as `development.local.php` when enabling development mode - activates error handlers
57+
* `doctrine.global.php`: configuration used by Object–relational mapping
58+
* `error-handling.global.php`: configures and activates error logs
59+
* `local.php.dist`: local config file where you can overwrite application name and URL
60+
* `local.test.php.dist`: local configuration for functional tests
61+
* `mail.local.php.dist`: mail configuration; e.g. sendmail vs smtp, message configuration, mail logging
62+
* `mezzio.global.php`: Mezzio core config file
63+
* `mezzio-tooling-factories.global.php`: add or remove factory definitions
64+
* `response-header.global.php`: defines headers per route
65+
* `templates.global.php`: dotkernel/dot-twigrenderer config file
66+
67+
### `data` directory
68+
69+
This directory is a storage for project data files and service caches.
70+
It contains these folders:
71+
72+
* `cache`: cache for e.g. Twig files
73+
* `doctrine`: database migrations and fixtures
74+
* `oauth`: encryption, private and public keys needed for authentication
75+
* `data/lock` - lock files generated by [`dotkernel/dot-cli`](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
76+
77+
> AVOID storing sensitive data on VCS.
78+
79+
### `log` directory
80+
81+
This directory stores daily log files.
82+
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+
84+
### `public` directory
85+
86+
This directory contains all publicly available assets and serves as the entry point of the application:
87+
88+
* `uploads`: a folder that normally contains files uploaded via the application
89+
* `.htaccess`: server configuration file used by Apache web server; it enables the URL rewrite functionality
90+
* `index.php`: the application's main entry point
91+
* `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+
2793
## `src` directory
2894

29-
This directory contains all source code related to the Module. It should contain following directories, if they’re not empty:
95+
This folder contains a separate folder for each Module.
96+
Each Module folder, in turn, should contain following directories, unless they are empty:
3097

3198
* Handler - Action classes (similar to Controllers but can only perform one action)
32-
* Entity - For database entities
99+
* Entity - Used by database entities
33100
* Service - Service classes
34101
* Collection - Database entities collections
35102
* Repository - Entity repository folder
36103

37-
> The above example is just some of the directories a project may include, but these should give you an idea of how the structure should look like.
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.
38105
39106
Other classes in the `src` directory may include `InputFilter`, `EventListener`, `Helper`, `Command`, `Factory` etc.
40107

41-
The `src` directory should also contain 2 files:
108+
The `src` directory normally also contains these files:
42109

43-
* `ConfigProvider.php` - Provides configuration data
44-
* `RoutesDelegator.php` - Module main routes entry file
110+
* `ConfigProvider.php` - Configuration data for the module
111+
* `OpenAPI.php` - Detailed descriptions for each endpoint in the OpenAPI format
112+
* `RoutesDelegator.php` - Module specific route registrations Module main routes entry file
45113

46114
## `templates` directory
47115

48116
This directory contains the template files, used for example to help render e-mail templates.
49117

50118
> Dotkernel API uses twig as Templating Engine. All template files have the extension .html.twig
51-
52-
## `data` directory
53-
54-
This directory contains project-related data (such as cache, file uploads)
55-
56-
We recommend using the following directory structure:
57-
58-
* `data/cache` - location where caches are stored
59-
* `data/oauth` - encryption, private and public keys needed for authentication.
60-
* `data/doctrine` - fixtures and migrations
61-
* `data/lock` - lock files generated by `dotkernel/dot-cli` [See more](https://docs.dotkernel.org/dot-cli/v3/lock-files/)

docs/book/v5/introduction/psr.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,35 @@ Some of the PSRs on this list are at the core of Dotkernel API, but several othe
44
Below is the full list of PSRs present in Dotkernel API and their purpose.
55

66
* PSR-3: [Logger Interface](https://www.php-fig.org/psr/psr-3/)
7-
* Interface for logging libraries.
7+
* Interface for logging libraries
8+
* Interfaces implemented in [php-fig/log](https://github.com/php-fig/log)
89
* PSR-4: [Autoloader](https://www.php-fig.org/psr/psr-4/)
9-
* Autoloading classes from file paths.
10+
* Autoloading classes from file paths
11+
* Interfaces implemented in [laminas/laminas-loader](https://github.com/laminas/laminas-loader)
1012
* PSR-6: [Caching Interface](https://www.php-fig.org/psr/psr-6/)
11-
* Interface for caching systems to improve the performance of any project.
13+
* Interface for caching systems to improve the performance of any project
14+
* Interfaces implemented in [php-fig/cache](https://github.com/php-fig/cache)
1215
* PSR-7: [HTTP message interfaces](https://www.php-fig.org/psr/psr-7/)
13-
* Interfaces for representing HTTP messages and URIs for use with HTTP messages.
16+
* Interfaces for representing HTTP messages and URIs for use with HTTP messages
17+
* Interfaces implemented in [php-fig/http-message](https://github.com/php-fig/http-message)
1418
* PSR-11: [Container interface](https://www.php-fig.org/psr/psr-11/)
15-
* Interface for dependency injection containers.
19+
* Interface for dependency injection containers
20+
* Interfaces implemented in [php-fig/container](https://github.com/php-fig/container)
1621
* PSR-13: [Link definition interfaces](https://www.php-fig.org/psr/psr-13/)
17-
* Way of representing a hypermedia link independently of the serialization format.
22+
* Way of representing a hypermedia link independently of the serialization format
23+
* Interfaces implemented in [php-fig/link](https://github.com/php-fig/link)
1824
* PSR-14: [Event Dispatcher](https://www.php-fig.org/psr/psr-14/)
19-
* Mechanism for event-based extension and collaboration.
25+
* Mechanism for event-based extension and collaboration
26+
* Interfaces implemented in [php-fig/event-dispatcher](https://github.com/php-fig/event-dispatcher)
2027
* PSR-15: [HTTP Server Request Handlers](https://www.php-fig.org/psr/psr-15/)
21-
* Interfaces for HTTP server request handlers and HTTP server middleware components that use HTTP messages.
28+
* Interfaces for HTTP server request handlers and HTTP server middleware components that use HTTP messages
29+
* Interfaces implemented in [php-fig/http-server-handler](https://github.com/php-fig/http-server-handler) and [php-fig/http-server-middleware](https://github.com/php-fig/http-server-middleware)
2230
* PSR-17: [HTTP Factories](https://www.php-fig.org/psr/psr-17/)
23-
* Standard for factories that create PSR-7 compliant HTTP objects.
31+
* Standard for factories that create PSR-7 compliant HTTP objects
32+
* Interfaces implemented in [php-fig/http-factory](https://github.com/php-fig/http-factory)
2433
* PSR-18: [HTTP Client](https://www.php-fig.org/psr/psr-18/)
25-
* Interface for sending HTTP requests and receiving HTTP responses.
34+
* Interface for sending HTTP requests and receiving HTTP responses
35+
* Interfaces implemented in [php-fig/http-client](https://github.com/php-fig/http-client)
2636
* PSR-20: [Clock](https://www.php-fig.org/psr/psr-20/)
27-
* Interface for reading the system clock.
37+
* Interface for reading the system clock
38+
* Interfaces implemented in [php-fig/clock](https://github.com/php-fig/clock)

0 commit comments

Comments
 (0)