I have a tiny application that i need an autoloader for. I could easily use the symfony2 class loader but it seems like overkill.
Is there a stable extremely lightweight psr-0 autloader out there?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You ask extremely lightweight, let’s do so 😉
Timothy Boronczyk wrote a nice minimal SPL autoloader : http://zaemis.blogspot.fr/2012/05/writing-minimal-psr-0-autoloader.html
I condensed the code like this:
Then compare (minified versions of) this [autoload3] with short @Alix Axel code [autoload4] :
autoload3 is the shortest !
Let’s use stable & extremely lightweight (175b !) autoloader file :
Maybe i’m crazy but you Asked for extreme, no?
EDIT: Thanks to Alix Axel, i’ve shorten the code (only 100b !) and used include instead of require in case you have various autoloading strategy for old libs (and then various autoloader in spl autoload stack…).
If you want to make it shorter / better, please use this gist.