Are there best practices for structuring PHP projects to avoid the need for repetitive includes?

When working on PHP projects, it's common to have multiple files that need to be included in order to access functions or classes. To avoid the need for repetitive includes, you can use the autoloading feature provided by PHP. By defining an autoloader function that maps class names to file paths, you can ensure that classes are automatically included when they are needed.

// Define an autoloader function
spl_autoload_register(function ($class) {
    include 'path/to/classes/' . $class . '.php';
});

// Now you can instantiate classes without needing to include them explicitly
$obj = new MyClass();