This may seem obvious, but check this scenario. You have a class folder:
+ class
--classA.php
--classB.php
--classC.php
--mainClass.php
Here... classA, classB, classC all extend the mainClass.
If you try to create a function that automatically includes all of the classes in a folder, normally, they are included alphabetically.
When you try to instantiate classC, for example, you will get an error:
"Cannot inherit from undefined class mainClass"
EVEN IF you instantiate the mainClass before you instantiate all of the other classes.
In other words, make sure your primary class is included before all others.