PHP-FIG: PSR-0

Place to place any code snippets, completed games, or even uncompleted games for IR users to use.
Post Reply
nand
Posts: 6
Joined: Thu Mar 14, 2013 4:47 pm

PHP-FIG: PSR-0

Post 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.
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: PHP-FIG: PSR-0

Post 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.
Creator of Dot World Maker
Mad programmer and annoying composer
Post Reply

Return to “Code Sharing”