Created
March 30, 2012 10:28
-
-
Save juzna/2250659 to your computer and use it in GitHub Desktop.
Nette skeleton autoload
This file contains 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 | |
/** | |
* Class loader for the whole application | |
* | |
* Makes sure all the classes are available when they're needed. No less, no more. | |
* Usually the first file to load in your app | |
* | |
* @author Jan Dolecek <juzna.cz@gmail.com> | |
* @author Filip Procházka (filip.prochazka@kdyby.org) | |
*/ | |
use Doctrine\Common\Annotations\AnnotationRegistry; | |
// load Nette Framework first | |
require_once __DIR__ . '/../vendor/Nette/Nette/loader.php'; | |
require_once __DIR__ . '/../libs/Coronel/loader.php'; | |
// require class loader | |
require_once __DIR__ . '/../vendor/Symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | |
// libraries | |
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader(); | |
$loader->registerNamespaces(array( | |
'Symfony' => __DIR__ . '/../vendor/Symfony/src', | |
'Doctrine\\Common' => __DIR__ . '/../vendor/Doctrine-Common/lib', | |
'Doctrine\\DBAL\\Migrations' => __DIR__ . '/../vendor/Doctrine-Migrations/lib', | |
'Doctrine\\DBAL' => __DIR__ . '/../vendor/Doctrine-DBAL/lib', | |
'Doctrine\\ORM' => __DIR__ . '/../vendor/Doctrine-ORM/lib', | |
'Gedmo' => __DIR__ . '/../vendor/Doctrine-Extensions/lib', | |
)); | |
$loader->register(); | |
// annotations | |
AnnotationRegistry::registerLoader(function ($class) use ($loader) { | |
$loader->loadClass($class); | |
return class_exists($class, FALSE); | |
}); | |
AnnotationRegistry::registerFile(__DIR__ . '/../vendor/Doctrine-ORM/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); | |
AnnotationRegistry::registerFile(__DIR__ . '/../libs/Coronel/Doctrine/Mapping/DoctrineAnnotations.php'); | |
// robot loader for my convenience | |
$robot = new Nette\Loaders\RobotLoader; | |
$robot->setCacheStorage(new Nette\Caching\Storages\MemoryStorage()); // FIXME: shouldn't be here | |
$robot->addDirectory(__DIR__); | |
$robot->addDirectory(__DIR__ . '/../libs/'); | |
$robot->register(); | |
unset($loader, $robot); // cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment