NYCPHP Meetup

NYPHP.org

[nycphp-talk] php autoloading

Paul A Houle paul at devonianfarm.com
Mon Jan 12 11:13:35 EST 2009


     I've recently written a "framework" that's part of a planned 
software product line.  One of the consequences is that I've written 
command-line PHP scripts that need to deal with objects that didn't 
exist when the script was written,  so I needed an autoloader.

    I did some research and I was really impressed with A.J. Brown's 
dynamic autoloader:

http://ajbrown.org/blog/2008/12/02/an-auto-loader-using-php-tokenizer.html

    Rather than assuming a certain convention for how file names relate 
to class names,  it scans directory trees,  parses files and creates a 
mapping.  This adds some overhead,  but that can be reduced by using 
serialize() to cache the result.  I've written some thought about this up:

http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/

    Any thoughts?




More information about the talk mailing list