Created
April 28, 2015 09:36
-
-
Save eniuz/828971717b376872b06c to your computer and use it in GitHub Desktop.
Faster Autoload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This code has being taken from Patrick Allert's article: | |
*/ | |
spl_autoload_register( | |
function ( $className ) | |
{ | |
if ( | |
strpos( $className, "Symfony\\" ) === 0 || | |
strpos( $className, "Sensio\\" ) === 0 || | |
strpos( $className, "eZ\\" ) === 0 || | |
strpos( $className, "EzSystems\\" ) === 0 || | |
strpos( $className, "Monolog\\" ) === 0 || | |
strpos( $className, "Psr\\" ) === 0 || | |
strpos( $className, "Twig_" ) === 0 || | |
strpos( $className, "Assetic\\" ) === 0 | |
) | |
{ | |
if ( | |
file_exists( | |
$path = __DIR__ . "/../vendor/PSR-0/" . str_replace( array( "_", "\\" ), "/", $className ) . ".php" | |
) | |
) | |
{ | |
require $path; | |
} | |
} | |
else | |
{ | |
return; | |
} | |
}, | |
true | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment