Created
March 16, 2016 13:13
-
-
Save pounard/80d957dba47d915b6a78 to your computer and use it in GitHub Desktop.
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
# mon_module/ | |
# ma_library/src/Toto.php <- namespace de ma library, par exmple Ma\Library\Toto | |
# mon_module.module | |
# Dans mon_module.module, genre en haut: | |
spl_autoload_register(function ($class) { | |
$parts = explode('\\', $class); | |
if ('Ma' === $parts[0] && 'Library' === $parts[1]) { | |
array_shift($parts); // enleve 'Ma' | |
array_shift($parts); // enleve 'Library' | |
$file = __DIR__ . '/ma_library/src/' . implode('/', $parts) . '.php'; | |
if (file_exists($file)) { | |
return include_once $file; | |
} | |
} | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment