public/index.php is now more than 150 lines long, and Madame Lou gets lost in it. To find the Annonce class, she has to scroll through the whole page. In a PHP project, each class has its own file, kept in src/.
Your mission
- Move each declaration into its own file in
src/, named after it:src/Publication.php,src/Rubrique.php,src/Auteur.php,src/Article.php,src/Annonce.phpandsrc/Sommaire.php. The files are waiting for you, empty. - In
public/index.php, load them withrequire_once, starting from__DIR__, following the patternrequire_once __DIR__ . '/../src/Article.php';. - Mind the order: a class cannot implement an interface that is not loaded yet.
The front page does not change, but the code becomes readable.
Reminder
require_once runs another PHP file, as if it were pasted right there, and only once, even if it is asked for twice. __DIR__ holds the folder of the current file: a path built from it works wherever the script is run from.