Skip to content

Application Structure Description

sunrise-php edited this page Jan 7, 2019 · 2 revisions

Base structure of the application

β”œβ”€β”€ config
β”‚Β Β  β”œβ”€β”€ cli-config.php
β”‚Β Β  β”œβ”€β”€ container.php
β”‚Β Β  β”œβ”€β”€ definitions.php
β”‚Β Β  └── environment.php
β”œβ”€β”€ public
β”‚Β Β  └── index.php
β”œβ”€β”€ src
β”‚Β Β  β”œβ”€β”€ Entity
β”‚Β Β  β”‚Β Β  └── AbstractEntity.php
β”‚Β Β  β”œβ”€β”€ Exception
β”‚Β Β  └── Http
β”‚Β Β      β”œβ”€β”€ Controller
β”‚Β Β      β”‚Β Β  └── HomeController.php
β”‚Β Β      β”œβ”€β”€ Middleware
β”‚Β Β      └── App.php
└── tests

Directories description

Directory Description
config Must contain the application configs
public Must contain the application entry point and any public files
src Must contain the application classes
src/Entity Must contain the application models (entities for Doctrine ORM)
src/Exception Must contain the application exceptions
src/Http/Controller Must contain the application controllers
src/Http/Middleware Must contain the application middlewares
tests Must contain any tests for the application

Files description

File Description
config/cli-config.php Setup to run Doctrine in CLI mode (source)
config/container.php PHP-DI build (source)
config/definitions.php The application dependencies
config/environment.php The application environment options
public/index.php The application entry point (the web server should proxy to this file, and only to it)
src/Entity/AbstractEntity.php All models (entities) must be extended by it class for validation to be available
src/Http/Controller/HomeController.php Demo controller for home page
src/Http/App.php This class runs the application