What are the drawbacks of manually listing every included page in PHP, and what alternative solutions exist?

Manually listing every included page in PHP can be time-consuming and prone to errors, especially as the project grows in size. An alternative solution is to use a directory scanning function to automatically include all PHP files within a specified directory.

// Automatically include all PHP files in a directory
$directory = 'includes/';
$files = glob($directory . '*.php');

foreach ($files as $file) {
    include $file;
}