It does require some forethought and organization: you cannot get autoload() to work (at least not very easily) if the classes you want it to load are scattered willy-nilly around your file system and with no sort of naming convention that can be used to identify where they are. But if you do have a scheme, it can be fairly easy. Suppose you have the following class directory/file hierarchy:
www
|
+--classes
|
+--control
| |
| +--foo.php [class name: Control_Foo]
| |
| +--bar.php [class name: Control_Bar]
|
+--model
|
+--this.php [class name: Model_This]
|
+--that.php [class name: Model_That]
Then your __autoload() might be:
function __autoload($className)
{
$path = strtolower(str_replace('_', '/', $className)) . '.php';
require_once($_SERVER['DOCUMENT_ROOT'] . '/classes/' . $path);
}