How can one ensure code organization and maintainability when working with includes in PHP projects?

To ensure code organization and maintainability when working with includes in PHP projects, it is important to follow a consistent naming convention for files, use namespaces to group related files together, and avoid using too many includes in a single file. Additionally, consider using autoloading mechanisms such as Composer's PSR-4 autoloading to automatically load classes without the need for manual includes.

// Example of using namespaces and autoloading in PHP

// File: MyClass.php
namespace MyNamespace;

class MyClass {
    public function __construct() {
        echo 'This is an example class';
    }
}

// File: index.php
require 'vendor/autoload.php'; // Composer autoloader

use MyNamespace\MyClass;

$myClass = new MyClass();