Page 1 of 1

PHP-FIG: PSR-0

Posted: Thu Mar 14, 2013 6:16 pm
by nand
Hi guys,

I thought I'd share a default PSR-0 autoloader implementation with everyone.
I've been using it on a few projects of mine, and it works quite well. The only modification I made to the default specification is adding the ability to use primitive resolvers.

Sample usage:

Code: Select all

// create an array that maps resolvers
$resolvers = array(
  'library' => 'some/other/path'
);

// populate the autoloader with a namespace, path and resolvers
$autoloader = new Autoloader('Application', getcwd(), $resolvers);
$autoloader->register();
Code: http://katelyn.nand.co.za/get/PSR-0-Autoloader.tgz

Enjoy.

Re: PHP-FIG: PSR-0

Posted: Sun Apr 14, 2013 4:41 am
by a_bertrand
Thanks for sharing, but would you mind to explain to those ignorant of us what an autoloader is, and why you should use one?

BTW Here PHP shines again by its absurdity: why autoload doesn't work in CLI mode? And why after creating a function, they declare they may stop using it soon and push people to use another one which does basically the same thing plus a bit more. Sorry, but some times PHP can be really odd.