Skip to content

Commit ab4e16e

Browse files
committed
updated file structure page
Signed-off-by: bidi <[email protected]>
1 parent fd31b43 commit ab4e16e

File tree

1 file changed

+92
-34
lines changed

1 file changed

+92
-34
lines changed

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

Lines changed: 92 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,112 @@ When using Dotkernel Admin the following structure is installed by default:
88

99
![Dotkernel Admin File Structure!](https://docs.dotkernel.org/img/admin/file-structure-dk-admin.jpg)
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-
* `log` - Storage of log files generated by dot-error-log library
17-
* `public` - Publicly visible files. The webserver need to have this folder as www-document root folder.
18-
* `src` - Should contain the source code files
19-
* `test` - Should contain the test files
20-
2111
## Special purpose folders
2212

23-
* `.github` - Contains workflow files
13+
* `.github` - Contains GitHub workflow files
2414
* `.laminas-ci` - Contains laminas-ci workflow files
2515

26-
## `src` directory
16+
## `bin` folder
2717

28-
This directory contains all source code related to the Module.
29-
It should contain the following directories, if they are not empty:
18+
This folder contents are
3019

31-
* Handler - Action classes (similar to Controllers but can only perform one action)
32-
* Entity - Database entities
33-
* Service - Service classes
34-
* Collection - Database entities collections
35-
* Repository - Entity repository folder
20+
* `clear-config-cache.php` - Removes the config cache file `data/cache/config-cache.php`; available only when development mode is enabled
21+
* `cli.php` - Used to build console applications based on [laminas-cli](https://github.com/laminas/laminas-cli)
22+
* `doctrine` - Used by the doctrine fixtures to populate the database tables
3623

37-
> The above example lists just a part of the directories in a project, but it should give you an idea of what the structure should look like.
24+
## `config` folder
3825

39-
Other classes in the `src` directory may include `InputFilter`, `EventListener`, `Helper`, `Command`, `Factory` etc.
26+
This folder contains all application-related config files:
4027

41-
The `src` directory should also contain 2 files:
28+
* `cli-config.php` - Command line interface configuration used by migrations, fixtures, crons
29+
* `config.php` - Registers ConfigProviders for installing packages
30+
* `container.php` - Main service container that provides access to all registered services
31+
* `development.config.php.dist` - Activates debug mode; gets symlinked as `development.config.php` when enabling development mode
32+
* `migrations.php` - Configuration for database migration, like migration file location and table to save the migration log
33+
* `pipeline.php` - Contains a list of middlewares, in the order of their execution
34+
* `twig-cs-fixer.php` - Configuration file for Twig code style checker/fixer
4235

43-
* `ConfigProvider.php` - Provides configuration data
44-
* `RoutesDelegator.php` - Module main routes entry file
36+
### `config/autoload` folder
4537

46-
## `templates` directory for modules
38+
This folder contains all service-related local and global config files:
4739

48-
This directory contains the template files, used for example to help render e-mail templates.
40+
* `app.global.php` - Configures basic app variables
41+
* `authentication.global.php` - Defines the Admin identity
42+
* `authorization.global.php` - Configures permissions for user roles
43+
* `authorization-guards.global.php` - Configures access per route for user roles
44+
* `cli.global.php` - Configures cli
45+
* `cors.global.php` - Configures Cross-Origin Resource Sharing, like call origin, headers, cookies
46+
* `dependencies.global.php` - Config file to set global dependencies that should be accessible by all modules
47+
* `development.local.php.dist` - Gets symlinked as `development.local.php` when enabling development mode; activates error handlers
48+
* `doctrine.global.php` - Configuration used by Object–relational mapping
49+
* `error-handling.global.php` - Configures and activates error logs
50+
* `local.php.dist` - Local config file where you can overwrite application name and URL
51+
* `local.test.php.dist` - Local configuration for functional tests
52+
* `mail.local.php.dist` - Mail configuration; e.g. sendmail vs smtp, message configuration, mail logging
53+
* `mezzio.global.php` - Mezzio core config file
54+
* `navigation.global.php` - Configures the top menu
55+
* `session.global.php` - Configures the session
56+
* `templates.global.php` - dotkernel/dot-twigrenderer config file
4957

50-
> Dotkernel Admin uses `twig` as Templating Engine.
51-
> All template files have the extension `.html.twig`.
58+
## `data` folder
59+
60+
This folder is a storage for project data files and service caches.
61+
It contains these folders:
62+
63+
* `cache` - Cache for e.g. Twig files
64+
* `doctrine` - Database migrations and fixtures
65+
* `geoip` - Holds the GeoLite2 databases
66+
* `lock` - Contains lock files generated by [`dotkernel/dot-cli`](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
67+
68+
> AVOID storing sensitive data on the repository!
69+
70+
## `log` folder
71+
72+
This folder stores daily log files.
73+
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.
74+
75+
## `public` folder
76+
77+
This folder contains all publicly available assets and serves as the entry point of the application:
78+
79+
* `css` and `js` - Contains the css and js file(s) generated by the webpack (npm) from the assets folder
80+
* `fonts` and `images` - Contain the font and image file(s) copied by the webpack (npm) from the assets folder
81+
* `uploads` - a folder that normally contains admin avatar images
82+
* `.htaccess` - server configuration file used by Apache web server; it enables the URL rewrite functionality
83+
* `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
5285

53-
## `data` directory
86+
## `src` folder
5487

55-
This directory contains project-related data, like cache and file uploads.
88+
This folder contains a separate folder for each Module.
5689

57-
We recommend using the following directory structure:
90+
These are the modules included by default:
5891

59-
* `data/cache` - Location where caches are stored
60-
* `data/doctrine` - Fixtures and migrations
61-
* `data/lock` - Lock files generated by [dotkernel/dot-cli](https://docs.dotkernel.org/dot-cli/v3/lock-files/)
92+
* `Admin` - Contains functionality for managing users with `admin` role; note these are users save in the `admin` database table
93+
* `App` - Contains core functionality, from authentication, to rendering, to error reporting
94+
* `Setting` - Contains functionality for saving and reading display settings
95+
96+
### Module contents
97+
98+
Each Module folder, in turn, should contain the following folders, unless they are empty:
99+
100+
* `src/Controller` - Action classes
101+
* `src/Entity` - Used by database entities
102+
* `src/Repository` - Entity repository folder
103+
* `src/Service` - Service classes
104+
105+
The above example is just some of the folders a project may include, but they should give you an idea about the recommended structure.
106+
Other classes the `src` folder may include are `InputFilter`, `EventListener`, `Helper`, `Command`, `Factory` etc.
107+
108+
The `src` folder in each Module folder normally also contains these files:
109+
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
113+
114+
### `templates` folder for modules
115+
116+
This folder contains the template files, used for example to help render e-mail templates.
117+
118+
> `twig` is used as Templating Engine.
119+
> All template files have the extension `.html.twig`.

0 commit comments

Comments
 (0)