If you are working with object oriented programming in php (which you definitely should) this is probably the easies way of autoloading your classes:
1. Only have one class per file
2. Name the files exactly as your classes are named
E.g. class customer goes into file customer.php:
3. Use directory structure namespaces
Namespaces must follow your directory structure, e.g.
Classes in directory /services/repositories/ have the following namespace:
4. Register automatic class autoloading
Place this first in your index.php file:
All you have to do now is to call your classes by name and it will work without you having to include all the directories, eg:
$customerrepository = new services\repositories\customerrepository();
You can use either the fully-qualified class name when refering to the class or use the use-statement to specify which class you are refering to.