The Dotkernel API file structure follows the PSR-4 standards. Standardizing the file structure of your project is considered good practice because it makes it easier to find and navigate the code.
When using Dotkernel API, the following structure is installed by default:
.github- Contains GitHub workflow files.laminas-ci- Contains laminas-ci workflow files
This folder contains:
clear-config-cache.php- Removes the config cache filedata/cache/config-cache.php; available only when development mode is enabledcli.php- Used to build console applications based on laminas-clidoctrine- Used by the doctrine fixtures to populate the database tables
This folder contains all application-related config files:
cli-config.php- Command line interface configuration used by migrations, fixtures, cron jobsconfig.php- Registers ConfigProviders for installing packagescontainer.php- Main service container that provides access to all registered servicesdevelopment.config.php.dist- Activates debug mode; gets symlinked asdevelopment.config.phpwhen enabling development modemigrations.php- Configuration for database migration, like migration file location and table to save the migration logpipeline.php- Contains a list of middlewares, in the order of their execution
This folder contains all service-related local and global config files:
authorization.global.php- Configures access per route for user rolescli.global.php- Configures clicontent-negotiation.global.php- Configures request and response formatscors.local.php.dist- Configures Cross-Origin Resource Sharing, like call origin, headers, cookiesdependencies.global.php- Sets global dependencies that should be accessible by all modulesdevelopment.local.php.dist- Gets symlinked asdevelopment.local.phpwhen enabling development mode; activates error handlersdoctrine.global.php- Configuration used by Object–relational mappingerror-handling.global.php- Configures and activates error logslocal.php.dist- Local configuration file where you can overwrite application name and URLlocal.test.php.dist- Local configuration for functional testsmail.local.php.dist- Mail configuration; e.g. sendmail vs smtp, message configuration, mail loggingmezzio.global.php- Mezzio core config filemezzio-tooling-factories.global.phpAdd or remove factory definitionsresponse-header.global.php- Defines headers per routetemplates.global.php-dotkernel/dot-twigrendererconfig file
This folder is a storage for project data files and service caches. It contains these folders:
cache- Cache for e.g. Twig filesdoctrine- Database migrations and fixturesoauth- Encryption, private and public keys needed for authenticationlock- Contains lock files generated bydotkernel/dot-cli
AVOID storing sensitive data on the repository!
This folder stores daily log files.
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.
This folder contains all publicly available assets and serves as the entry point of the application:
uploads- Normally contains files uploaded via the application.htaccess- Server configuration file used by Apache web server; it enables the URL rewrite functionalityindex.php- The application's main entry pointrobots.txt.dist- A sample robots.txt file that allows/denies bot access to certain areas of your application; activate it by duplicating the file asrobots.txtand comment out the lines that don't match your environment
This folder contains a separate folder for each Module.
These are the modules included by default:
Admin- Contains functionality for managing users withadminrole; note these are users save in theadmindatabase tableApp- Contains functionality such as error reportingCore- Contains core functionality, from authentication, to renderingSecurity- Contains security-related functionalityUser- Contains functionality for managing regular users
Each Module folder, in turn, should contain the following folders, unless they are empty:
src/Handler- Action classes (similar to Controllers but can only perform one action)src/Entity- Used by database entitiessrc/Service- Service classessrc/Repository- Entity repository folder
The above example is just some of the folders a project may include, but they should give you an idea about the recommended structure.
Other classes the src folder may include are InputFilter, EventListener, Helper, Command, Factory etc.
The src folder in each Module folder normally also contains these files:
ConfigProvider.php- Configuration data for the moduleOpenAPI.php- Detailed descriptions for each endpoint in the OpenAPI formatRoutesDelegator.php- Module specific route registrations
This folder contains the template files, used, for example, to help render e-mail templates.
twigis used as Templating Engine. All template files have the extension.html.twig
