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: docs/book/v7/introduction/file-structure.md
+61-23Lines changed: 61 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Summary
4
4
5
-
A tour of the directories a default Dotkernel API installation ships with — `bin` for CLI entry points, `config` and `config/autoload` for application and service configuration, `data` for caches, migrations and OAuth keys, `log` for daily logs, `public` as the web entry point, and `src` for the modules — plus the folders and files each module is expected to contain.
5
+
A tour of the directories a default Dotkernel API installation ships with — `bin` for CLI entry points, `config` and `config/autoload` for application and service configuration, `data` for caches, lock files and OAuth keys, `log` for daily logs, `public` as the web entry point, and `src` for the modules — plus the folders and files each module is expected to contain.
6
6
7
7
## Details
8
8
@@ -13,29 +13,37 @@ When using Dotkernel API, the following structure is installed by default:
13
13
14
14

*`.laminas-ci.json` - laminas-ci configuration; a single file, not a folder
20
+
*`documentation` - Postman and Bruno collections for the shipped endpoints, plus notes on the CLI commands
20
21
21
22
## `bin` folder
22
23
23
24
This folder contains:
24
25
25
-
*`clear-config-cache.php` - Removes the config cache file `data/cache/config-cache.php`; available only when development mode is enabled
26
+
*`clear-config-cache.php` - Removes the config cache file `data/cache/config-cache.php`; can also be invoked as `composer clear-config-cache`
26
27
*`cli.php` - Used to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli)
27
-
*`doctrine` - Used by the doctrine fixtures to populate the database tables
28
+
*`composer-post-install-script.php` - Runs after `composer install` and copies the shipped distributable config files into place; it asks nothing and needs no input
29
+
*`doctrine` - Doctrine ORM console, used by the fixtures commands to populate the database tables
30
+
*`generate-oauth2-keys.php` - Generates the OAuth2 key pair and encryption key into `data/oauth`
28
31
29
32
## `config` folder
30
33
31
34
This folder contains all application-related config files:
32
35
33
-
*`cli-config.php` - Command line interface configuration used by migrations, fixtures, cron jobs
34
-
*`config.php` - Registers ConfigProviders for installing packages
36
+
*`cli-config.php` - Doctrine Migrations entry point; builds the `DependencyFactory` from the `doctrine.migrations` config
37
+
*`config.php` - Registers ConfigProviders for installing packages, and sets the config cache path
35
38
*`container.php` - Main service container that provides access to all registered services
36
39
*`development.config.php.dist` - Activates debug mode; gets symlinked as `development.config.php` when enabling development mode
37
-
*`migrations.php` - Configuration for database migration, like migration file location and table to save the migration log
38
40
*`pipeline.php` - Contains a list of middlewares, in the order of their execution
41
+
*`routes.php` - Application-wide route registration; ships empty, because each module declares its own routes in its `RoutesDelegator`
42
+
43
+
### Note
44
+
45
+
> There is no `config/migrations.php`.
46
+
> Migration settings — the `doctrine_migration_versions` table and the `src/Core/src/App/src/Migration` path — are declared in `Core\App\ConfigProvider` and read through `config/cli-config.php`.
39
47
40
48
### `config/autoload` folder
41
49
@@ -46,29 +54,37 @@ This folder contains all service-related local and global config files:
46
54
*`content-negotiation.global.php` - Configures request and response formats
47
55
*`cors.local.php.dist` - Configures Cross-Origin Resource Sharing, like call origin, headers, cookies
48
56
*`dependencies.global.php` - Sets global dependencies that should be accessible by all modules
49
-
*`development.local.php.dist` - Gets symlinked as `development.local.php` when enabling development mode; activates error handlers
50
-
*`doctrine.global.php` - Configuration used by Object–relational mapping
57
+
*`development.local.php.dist` - Gets symlinked into place when enabling development mode; activates error handlers
51
58
*`error-handling.global.php` - Configures and activates error logs
52
-
*`local.php.dist` - Local configuration file where you can overwrite application name and URL
59
+
*`local.php.dist` - Local configuration file: database credentials, application name and URL, OAuth2 key paths
53
60
*`local.test.php.dist` - Local configuration for functional tests
54
-
*`mail.local.php.dist` - Mail configuration; e.g. sendmail vs smtp, message configuration, mail logging
61
+
*`mail.local.php.dist` - Mail configuration; e.g. sendmail vs smtp, message configuration, mail logging. Not committed: the post-install script copies it out of `dotkernel/dot-mail` during installation
55
62
*`mezzio.global.php` - Mezzio core config file
56
-
*`mezzio-tooling-factories.global.php` Add or remove factory definitions
63
+
*`problem-details.global.php`- Maps HTTP status codes to the `type` URI used in problem details responses
57
64
*`response-header.global.php` - Defines headers per route
*`templates.global.php` - Configures `Api\App\Template\RendererInterface`, including the `phtml` template extension
66
+
67
+
### Note
68
+
69
+
> Doctrine is **not** configured from this folder.
70
+
> There is no `doctrine.global.php`; ORM, migration and fixture settings come from the module `ConfigProvider`s, and connection credentials from the local config file.
59
71
60
72
## `data` folder
61
73
62
74
This folder is a storage for project data files and service caches.
63
75
It contains these folders:
64
76
65
-
*`cache` - Cache for e.g. Twig files
66
-
*`doctrine` - Database migrations and fixtures
77
+
*`cache` - Holds `config-cache.php`, the merged configuration cache written when `ConfigAggregator::ENABLE_CACHE` is on
67
78
*`oauth` - Encryption, private and public keys needed for authentication
68
79
*`lock` - Contains lock files generated by [`dotkernel/dot-cli`](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
69
80
70
81
> AVOID storing sensitive data on the repository!
71
82
83
+
### Note
84
+
85
+
> There is no `data/doctrine`.
86
+
> Migrations live in `src/Core/src/App/src/Migration` and fixtures in `src/Core/src/App/src/Fixture`, both inside the `Core` module.
87
+
72
88
## `log` folder
73
89
74
90
This folder stores daily log files.
@@ -80,8 +96,10 @@ This folder contains all publicly available assets and serves as the entry point
80
96
81
97
*`uploads` - Normally contains files uploaded via the application
82
98
*`.htaccess` - Server configuration file used by Apache web server; it enables the URL rewrite functionality
99
+
*`.well-known` - Contains `security.txt`, the [RFC 9116](https://www.rfc-editor.org/rfc/rfc9116) contact file for reporting vulnerabilities
100
+
*`favicon.ico` - The site icon browsers request by default
83
101
*`index.php` - The application's main entry point
84
-
*`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
102
+
*`robots.txt` - Allows or denies bot access to parts of your application; it is a live file, so edit it to match your environment
85
103
86
104
## `src` folder
87
105
@@ -95,6 +113,9 @@ These are the modules included by default:
*`User` - Contains functionality for managing regular users
97
115
116
+
`Core` is itself split by domain under `src/Core/src`, into `Admin`, `App`, `Security`, `Setting` and `User`.
117
+
See [Core and App](../extended-features/core-and-app.md).
118
+
98
119
### Module contents
99
120
100
121
Each Module folder, in turn, should contain the following folders, unless they are empty:
@@ -116,9 +137,13 @@ The `src` folder in each Module folder normally also contains these files:
116
137
### `templates` folder in Modules
117
138
118
139
This folder contains the template files, used, for example, to help render e-mail templates.
140
+
Of the shipped modules only `User` has one, at `src/User/templates/user`.
141
+
142
+
> Templates are rendered by `Api\App\Template\Renderer`, a lightweight renderer for files combining PHP and HTML.
143
+
> All template files have the extension `.phtml`.
144
+
> The extension is set in `config/autoload/templates.global.php` and Twig is not used anywhere in the application.
119
145
120
-
> `twig` is used as Templating Engine.
121
-
> All template files have the extension `.html.twig`
146
+
See [Rendering and sending emails](../core-features/rendering-and-sending-emails.md).
122
147
123
148
## FAQ
124
149
@@ -155,17 +180,30 @@ Only the `public` folder is served directly; everything else is routed through i
155
180
A: `config/pipeline.php`, which lists the middlewares in execution order.
156
181
See [Middleware flow](../flow/middleware-flow.md).
157
182
183
+
**Q: Why is `config/routes.php` empty?**
184
+
185
+
A: Because routes are declared per module.
186
+
Each module's `RoutesDelegator` is registered as a delegator on `Mezzio\Application` in its `ConfigProvider`, so `config/routes.php` is left as an empty callable for application-wide routes you may want to add.
187
+
158
188
**Q: What is the difference between `config` and `config/autoload`?**
159
189
160
190
A: `config` holds application-level wiring — the container, the pipeline, the config aggregator.
161
-
`config/autoload` holds per-service configuration, split into `*.global.php` files that are committed and `*.local.php` files that are not.
191
+
`config/autoload` holds per-service configuration, split into committed `*.global.php` files and uncommitted local ones shipped via their distributable equivalents.
192
+
193
+
**Q: Where are the database migrations and fixtures?**
194
+
195
+
A: In `src/Core/src/App/src/Migration` and `src/Core/src/App/src/Fixture`.
196
+
Both paths are declared in `Core\App\ConfigProvider`, not in a file under `config`.
197
+
See [Generate database migrations](../commands/generate-database-migrations.md).
162
198
163
199
**Q: Where are the OAuth2 keys kept?**
164
200
165
201
A: In `data/oauth`.
166
-
They are generated during installation and must never be committed.
202
+
They are generated by `bin/generate-oauth2-keys.php`during installation and must never be committed.
167
203
See [OAuth2 security](../security/oauth2-security.md).
168
204
169
-
**Q: Why is `robots.txt` shipped as `robots.txt.dist`?**
205
+
**Q: Which templating engine is used?**
170
206
171
-
A: So you can activate it deliberately: copy it to `robots.txt` and comment out the lines that do not match your environment.
207
+
A: None of the usual ones.
208
+
`Api\App\Template\Renderer` renders `.phtml` files directly; there is no Twig anywhere in the codebase.
209
+
See [Rendering and sending emails](../core-features/rendering-and-sending-emails.md).
0 commit comments