Structure
On this page
Taking our directory structure from the API Tutorial we created here.
app
├── switches
├── services
├── authenticationBackends
├── commands
├── middlewares
├── routes.php
vendor
.gitignore
composer.json
composer.lock
index.php
pionia
README.md
settings.ini
Directory Structure Breakdown
app:- This is the main directory of the project. It is where all the application logic is stored. It contains the following subdirectories and scripts:
Name | Role | Type |
---|---|---|
switches | The switch is responsible for deciding which service to call based on the registered services. This is where all our service switches are stored. Every switch should be associated with a version of your api. If your api does not need more than one version, one switch is enough. | Folder |
services | This is where all our services are stored. This is where you should focus most. All business logic resides here. | Folder |
authenticationBackends | This is where we store our authentication backends. Add your authentication backend here and register it in settings.ini | Folder |
middlewares | This folder is not included in the initial project setup. But this is where you add your middlewares. Middlewares are used to intercept requests before they reach the switches and after they leave the switches. | Folder |
commands | This is where we store our console commands. Add your console commands here. | Folder |
routes.php | Our routes behave different, their job is not to not route but to register the switches that should be auto-dicovered. | File |
vendor:-
This is where all the dependencies of the project are stored. It is created by composer when you run composer install
or composer update
.
.gitignore:- This file is used to tell git which files to ignore when pushing to the repository.
composer.json:- This file is used to manage the dependencies of the project. It is used by composer to install the dependencies.
composer.lock:- This file is used to lock the dependencies of the project. It is used by composer to install the dependencies.
index.php:- This is the entry point of the project. It is where the project starts running. This is where you register the middlewares, routes, and authentication backends.
pionia:- This is our console interface. It helps us to run pionia-specific commands.
README.md:- A simple getting started guide for the project.
settings.ini:- This is the file that contains the settings of the project. It is where you store the settings of the project.
As you can see, pionia maintains the least number of files and directories to make it easy for you to understand and maintain your project. You can always add more directories and files as you see fit. But remember to keep the project as simple as possible.