I maintain a project that typically includes ~65 files per script execution. Most of them are function libraries and the functions have been separated into different files along their functionality.
I know that include(), include_once(), require(), require_once() are some of the most expensive calls to make due to having to read in the files, parse them, etc.
What I was wondering about is using PHP5 classes as poor man's namespaces and using __autoload() to require_once() them as needed.
So in a file named class.Foo.inc.php I would have:
class Foo {
static public function helloWorld() {
echo 'Hello World!!';
}
}
And in another script:
function __autoload($class_name) {
require_once './class.'.$class_name.'.inc.php';
}
Foo::helloWorld();
That way only the files that are actually used in that script instance are included, instead of the glut of my function libraries just-to-be-safe.
Are there any downsides to this?
Heavier memory usage?
__autoload() affecting performance?
Caching problems? (like with eAccelerator)
Any suggestions and information is greatly appreciated!!