If you’re like me, you like to dig into the belly of things and twist them to your own uses. Tonight, I’ve been monkeying around with ZF2 autoloaders, and working out how they function.
I store my ZF install in a dir (Zend/) in my include path, so I don’t have to maintain copies for each site on my server.
Some useful notes on this:
The stock ZF2 download does not include a pre-generated classmap file. To generate this, go into the default unpacked archive folder, into bin/ and run this command:
php classmap_generator.php -l "/usr/share/php/Zend/"
// How to get an absolute path to the generated classmap file (return: /usr/share/php/Zend/autoload_classmap.php)
$classmapPath = stream_resolve_include_path(‘Zend/autoload_classmap.php’);
// How to get the autoload up and running
$autoloader = new Zend\Loader\ClassMapAutoloader();
That’s all for tonight folks!