Skip to content

Commit 4f786f7

Browse files
authored
Merge pull request #172 from dotkernel/file-structure-accuracy
Correct v7 file structure page
2 parents 5a53ede + bf516ad commit 4f786f7

1 file changed

Lines changed: 61 additions & 23 deletions

File tree

‎docs/book/v7/introduction/file-structure.md‎

Lines changed: 61 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Summary
44

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

77
## Details
88

@@ -13,29 +13,37 @@ When using Dotkernel API, the following structure is installed by default:
1313

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

16-
## Special purpose folders
16+
## Special purpose folders and files
1717

1818
* `.github` - Contains GitHub workflow files
19-
* `.laminas-ci` - Contains laminas-ci workflow files
19+
* `.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
2021

2122
## `bin` folder
2223

2324
This folder contains:
2425

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`
2627
* `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`
2831

2932
## `config` folder
3033

3134
This folder contains all application-related config files:
3235

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
3538
* `container.php` - Main service container that provides access to all registered services
3639
* `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
3840
* `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`.
3947
4048
### `config/autoload` folder
4149

@@ -46,29 +54,37 @@ This folder contains all service-related local and global config files:
4654
* `content-negotiation.global.php` - Configures request and response formats
4755
* `cors.local.php.dist` - Configures Cross-Origin Resource Sharing, like call origin, headers, cookies
4856
* `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
5158
* `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
5360
* `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
5562
* `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
5764
* `response-header.global.php` - Defines headers per route
58-
* `templates.global.php` - `dotkernel/dot-twigrenderer` config file
65+
* `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.
5971
6072
## `data` folder
6173

6274
This folder is a storage for project data files and service caches.
6375
It contains these folders:
6476

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
6778
* `oauth` - Encryption, private and public keys needed for authentication
6879
* `lock` - Contains lock files generated by [`dotkernel/dot-cli`](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
6980

7081
> AVOID storing sensitive data on the repository!
7182
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+
7288
## `log` folder
7389

7490
This folder stores daily log files.
@@ -80,8 +96,10 @@ This folder contains all publicly available assets and serves as the entry point
8096

8197
* `uploads` - Normally contains files uploaded via the application
8298
* `.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
83101
* `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
85103

86104
## `src` folder
87105

@@ -95,6 +113,9 @@ These are the modules included by default:
95113
* `Security` - Contains security-related functionality
96114
* `User` - Contains functionality for managing regular users
97115

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+
98119
### Module contents
99120

100121
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:
116137
### `templates` folder in Modules
117138

118139
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.
119145
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).
122147

123148
## FAQ
124149

@@ -155,17 +180,30 @@ Only the `public` folder is served directly; everything else is routed through i
155180
A: `config/pipeline.php`, which lists the middlewares in execution order.
156181
See [Middleware flow](../flow/middleware-flow.md).
157182

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+
158188
**Q: What is the difference between `config` and `config/autoload`?**
159189

160190
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).
162198

163199
**Q: Where are the OAuth2 keys kept?**
164200

165201
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.
167203
See [OAuth2 security](../security/oauth2-security.md).
168204

169-
**Q: Why is `robots.txt` shipped as `robots.txt.dist`?**
205+
**Q: Which templating engine is used?**
170206

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

Comments
 (0)