Cours 40 — Organisation d’un projet Symfony
Introduction
Symfony impose une organisation claire des fichiers et des dossiers.
Cette structure facilite la maintenance et la compréhension du projet.
Dossier principal
Contient l’ensemble de l’application.
Dossier src
Contient le code PHP de l’application.
Contrôleurs
Exemple :
1
2
| PatientController.php
SejourController.php
|
Entités
Exemple :
1
2
3
| Patient.php
Sejour.php
User.php
|
Repositories
Exemple :
Exemple :
Services
Exemple :
Templates Twig
Exemple :
1
2
| templates/patient/
templates/sejour/
|
Fichiers publics
Contient :
1
2
3
4
| images
css
javascript
index.php
|
Configuration
Contient :
1
2
3
| services.yaml
routes.yaml
packages/
|
Migrations
Contient les fichiers de migration Doctrine.
Comprendre le projet
1
2
3
4
5
6
7
8
9
| Route
↓
Contrôleur
↓
Entity
↓
Repository
↓
Twig
|
Schéma simplifié
1
2
3
4
5
6
7
8
9
10
11
12
| src/
├── Controller
├── Entity
├── Repository
├── Form
└── Service
templates/
config/
public/
|
Conclusion
Symfony organise automatiquement les fichiers selon leur rôle.
Dossiers à retenir :
1
2
3
4
5
6
7
8
| Controller
Entity
Repository
Form
Service
templates
config
public
|