Skip to content

Instantly share code, notes, and snippets.

@alganet
Created May 10, 2011 14:18
Show Gist options
  • Save alganet/964558 to your computer and use it in GitHub Desktop.
Save alganet/964558 to your computer and use it in GitHub Desktop.
Lightweight PSR-0 compliant autoloader
<?php
spl_autoload_register(function ($className) {
$fileParts = explode('\\', ltrim($className, '\\'));
if (false !== strpos(end($fileParts), '_'))
array_splice($fileParts, -1, 1, explode('_', current($fileParts)));
require implode(DIRECTORY_SEPARATOR, $fileParts) . '.php';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment