What is the recommended approach for structuring a website with multiple subdirectories in PHP?

When structuring a website with multiple subdirectories in PHP, it is recommended to use a modular approach to keep the code organized and maintainable. One way to achieve this is by creating separate PHP files for each subdirectory, each containing related functions and classes. Then, use include or require statements to include these files in the main PHP files where they are needed.

// index.php
<?php
// Include files from subdirectories
require_once 'subdirectory1/functions.php';
require_once 'subdirectory2/classes.php';

// Use functions and classes from subdirectories
echo subdirectory1\hello();
$object = new subdirectory2\ExampleClass();
$object->method();
?>