/** * Initialise. * * Runs at plugin init time. * * @return void */ public function initialize() { $autoloader = new Zikula_KernelClassLoader(); $autoloader->spl_autoload_register(); $autoloader->register('Gedmo', __DIR__ . '/lib/vendor/l3pp4rd/DoctrineExtensions/lib', '\\'); $autoloader->register('DoctrineExtensions\\StandardFields', __DIR__ . '/lib', '\\'); $autoloader->register('DoctrineExtensions', __DIR__ . '/lib/vendor/beberlei/DoctrineExtensions/lib', '\\'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo', __DIR__ . '/lib/vendor/l3pp4rd/DoctrineExtensions/lib'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('DoctrineExtensions\\StandardFields', __DIR__ . '/lib'); include 'ExtensionsManager.php'; $definition = new Zikula_ServiceManager_Definition('SystemPlugins_DoctrineExtensions_ExtensionsManager', array(new Zikula_ServiceManager_Reference('doctrine.eventmanager'), new Zikula_ServiceManager_Reference('zikula.servicemanager'))); $this->serviceManager->registerService('doctrine_extensions', $definition); $types = array('Loggable', 'Sluggable', 'Timestampable', 'Translatable', 'Tree', 'Sortable'); foreach ($types as $type) { // The listener for Translatable is incorrectly named TranslationListener if ($type != "Translatable") { $definition = new Zikula_ServiceManager_Definition("Gedmo\\$type\\{$type}Listener"); } else { $definition = new Zikula_ServiceManager_Definition("Gedmo\\Translatable\\TranslationListener"); } $this->serviceManager->registerService(strtolower("doctrine_extensions.listener.$type"), $definition); } $definition = new Zikula_ServiceManager_Definition("DoctrineExtensions\\StandardFields\\StandardFieldsListener"); $this->serviceManager->registerService(strtolower("doctrine_extensions.listener.standardfields"), $definition); }
public function initialize() { return; // register symfony validation annorations Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Symfony\\Component\\Validator\\Constraints', __DIR__ . '/../../vendor/symfony/src'); // register validator service $fileLocator = new FileLocator(array(__DIR__ . '/Resources/config/validator.xml')); $xmlFileLoader = new XmlFileLoader($this->container->get('service_container'), $fileLocator); $xmlFileLoader->load(__DIR__ . '/Resources/config/validator.xml'); // setup symfony forms $registry = new \Zikula\Core\Forms\DoctrineRegistryImpl(); $csrf = new \Symfony\Component\Form\Extension\Csrf\CsrfExtension(new \Zikula\Core\Forms\ZikulaCsrfProvider()); $core = new \Symfony\Component\Form\Extension\Core\CoreExtension(); $validator = new \Symfony\Component\Form\Extension\Validator\ValidatorExtension($this->container->get("validator")); $zk = new \Zikula\Core\Forms\ZikulaExtension(); $doctrine = new \Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension($registry); $formFactory = new \Symfony\Component\Form\FormFactory(array($core, $csrf, $validator, $zk, $doctrine)); $this->container->set('symfony.formfactory', $formFactory); $formRenderer = new \Zikula\Core\Forms\FormRenderer($this->dispatcher); $this->container->set('symfony.formrenderer', $formRenderer); }
/** * Initialise. * * Runs at plugin init time. * * @return void */ public function initialize() { $autoloader = new UniversalClassLoader(); $autoloader->register(); $autoloader->register('DoctrineExtensions\\StandardFields', __DIR__ . '/lib'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo', dirname(__DIR__) . '/../vendor/gedmo/doctrine-extensions/lib'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('DoctrineExtensions\\StandardFields', __DIR__ . '/lib'); include 'ExtensionsManager.php'; $definition = new Definition('SystemPlugins_DoctrineExtensions_ExtensionsManager', array(new Reference('doctrine.eventmanager'), new Reference('service_container'))); $this->container->setDefinition('doctrine_extensions', $definition); $types = array('Loggable', 'Sluggable', 'Timestampable', 'Translatable', 'Tree', 'Sortable'); foreach ($types as $type) { // The listener for Translatable is incorrectly named TranslationListener if ($type != "Translatable") { $definition = new Definition("Gedmo\\{$type}\\{$type}Listener"); } else { $definition = new Definition("Gedmo\\Translatable\\TranslationListener"); } $this->container->setDefinition(strtolower("doctrine_extensions.listener.{$type}"), $definition); } $definition = new Definition("DoctrineExtensions\\StandardFields\\StandardFieldsListener"); $this->container->setDefinition(strtolower("doctrine_extensions.listener.standardfields"), $definition); }
public function initialize() { date_default_timezone_set('Europe/Prague'); Nette\Bridges\Framework\TracyBridge::initialize(); $this->getService('events.manager')->createEvent(array('Nette\\DI\\Container', 'onInitialize'))->dispatch($this); Tracy\Debugger::$email = '*****@*****.**'; Tracy\Debugger::$editor = 'sublime'; Tracy\Debugger::$browser = 'chromium-browser'; Tracy\Debugger::$strictMode = TRUE; Nette\Caching\Storages\FileStorage::$useDirectories = TRUE; $this->getByType("Nette\\Http\\Session")->exists() && $this->getByType("Nette\\Http\\Session")->start(); header('X-Frame-Options: SAMEORIGIN'); $this->getService('systemModule.initializer'); $this->getService('usersModule.initializer'); $this->getService('securityModule.initializer'); header('X-Powered-By: Nette Framework'); header('Content-Type: text/html; charset=utf-8'); Nette\Utils\SafeStream::register(); Nette\Reflection\AnnotationsParser::setCacheStorage($this->getByType("Nette\\Caching\\IStorage")); Nette\Reflection\AnnotationsParser::$autoRefresh = FALSE; Doctrine\Common\Annotations\AnnotationRegistry::registerLoader("class_exists"); Kdyby\Doctrine\Diagnostics\Panel::registerBluescreen($this); Kdyby\Doctrine\Proxy\ProxyAutoloader::create('/home/fuca/Projects/www/sportsclub/tests/tmp/proxies', 'Kdyby\\GeneratedProxy')->register(); Nette\Diagnostics\Debugger::getBlueScreen()->collapsePaths[] = '/home/fuca/Projects/www/sportsclub/vendor/kdyby/doctrine/src/Kdyby/Doctrine'; Nette\Diagnostics\Debugger::getBlueScreen()->collapsePaths[] = '/home/fuca/Projects/www/sportsclub/vendor/doctrine'; Nette\Diagnostics\Debugger::getBlueScreen()->collapsePaths[] = '/home/fuca/Projects/www/sportsclub/tests/tmp/proxies'; Kdyby\Translation\Diagnostics\Panel::registerBluescreen(); \Tracy\Debugger::setLogger($this->getService('monolog.adapter')); }
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ $loader = (require __DIR__ . '/../vendor/autoload.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) { return class_exists($class); });
<?php $loader = (require_once __DIR__ . "/../vendor/autoload.php"); $loader->add('LiteCQRS\\', __DIR__); Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
<?php require_once __DIR__ . '/../vendor/autoload.php'; Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists'); use Hateoas\Serializer\XmlHalSerializer; use Hateoas\Representation\Factory\PagerfantaFactory; use Hateoas\UrlGenerator\SymfonyUrlGenerator; use Hautelook\TemplatedUriRouter\Routing\Generator\Rfc6570Generator; use Propilex\Model\Document; use Propilex\Model\DocumentQuery; use Propilex\Model\Repository\PropelDocumentRepository; use Propilex\View\Error; use Propilex\View\FormErrors; use Propilex\View\ViewHandler; use Propilex\Hateoas\CuriesConfigurationExtension; use Propilex\Hateoas\TransExpressionFunction; use Propilex\Hateoas\VndErrorRepresentation; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Validator\Mapping\ClassMetadataFactory; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; $app = new Silex\Application(); // Providers $app->register(new Silex\Provider\ValidatorServiceProvider()); $app->register(new Silex\Provider\UrlGeneratorServiceProvider()); $app->register(new Propel\Silex\PropelServiceProvider(), array('propel.config_file' => __DIR__ . '/config/propel/propilex.php', 'propel.model_path' => __DIR__ . '/../src/Propilex/Model')); // Configure the validator service $app['validator.mapping.class_metadata_factory'] = new ClassMetadataFactory(new YamlFileLoader(__DIR__ . '/config/validation.yml')); // Configure Hateoas serializer $app['serializer'] = $app->share(function () use($app) { $jmsSerializerBuilder = JMS\Serializer\SerializerBuilder::create()->setMetadataDirs(array('' => __DIR__ . '/config/serializer', 'Propilex' => __DIR__ . '/config/serializer'))->setDebug($app['debug'])->setCacheDir(__DIR__ . '/cache/serializer');
<?php /* * Copyright 2011 Johannes M. Schmitt <*****@*****.**> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ include_once dirname(__DIR__) . '/vendor/autoload.php'; Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) { if (0 === strpos(ltrim($class, '/'), 'JMS\\SerializerBundle\\Annotation')) { if (file_exists($file = dirname(__DIR__) . '/' . substr(str_replace('\\', '/', $class), strlen('JMS\\SerializerBundle\\')) . '.php')) { require_once $file; } } return class_exists($class, false); });
* This is bootstrap for phpUnit unit tests, * use README.md for more details * * @author Gediminas Morkevicius <*****@*****.**> * @package Gedmo.Tests * @link http://www.gediminasm.org * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ if (!class_exists('PHPUnit_Framework_TestCase') || version_compare(PHPUnit_Runner_Version::id(), '3.5') < 0) { die('PHPUnit framework is required, at least 3.5 version'); } if (!class_exists('PHPUnit_Framework_MockObject_MockBuilder')) { die('PHPUnit MockObject plugin is required, at least 1.0.8 version'); } define('TESTS_PATH', __DIR__); define('TESTS_TEMP_DIR', __DIR__ . '/temp'); define('VENDOR_PATH', realpath(__DIR__ . '/../vendor')); $classLoaderFile = VENDOR_PATH . '/Symfony/Component/ClassLoader/UniversalClassLoader.php'; if (!file_exists($classLoaderFile)) { die('cannot find vendor, run: php bin/vendors.php'); } require_once $classLoaderFile; $loader = new Symfony\Component\ClassLoader\UniversalClassLoader(); $loader->registerNamespaces(array('Symfony' => VENDOR_PATH, 'Doctrine\\MongoDB' => VENDOR_PATH . '/doctrine-mongodb/lib', 'Doctrine\\ODM\\MongoDB' => VENDOR_PATH . '/doctrine-mongodb-odm/lib', 'Doctrine\\Common' => VENDOR_PATH . '/doctrine-common/lib', 'Doctrine\\DBAL' => VENDOR_PATH . '/doctrine-dbal/lib', 'Doctrine\\ORM' => VENDOR_PATH . '/doctrine-orm/lib', 'Gedmo\\Mapping\\Mock' => __DIR__, 'Gedmo' => __DIR__ . '/../lib', 'Tool' => __DIR__ . '/Gedmo', 'Translator\\Fixture' => __DIR__ . '/Gedmo', 'Translatable\\Fixture' => __DIR__ . '/Gedmo', 'Timestampable\\Fixture' => __DIR__ . '/Gedmo', 'Tree\\Fixture' => __DIR__ . '/Gedmo', 'Sluggable\\Fixture' => __DIR__ . '/Gedmo', 'Sortable\\Fixture' => __DIR__ . '/Gedmo', 'Mapping\\Fixture' => __DIR__ . '/Gedmo', 'Loggable\\Fixture' => __DIR__ . '/Gedmo', 'SoftDeleteable\\Fixture' => __DIR__ . '/Gedmo', 'Uploadable\\Fixture' => __DIR__ . '/Gedmo', 'Wrapper\\Fixture' => __DIR__ . '/Gedmo', 'Gedmo\\Uploadable\\Stub' => __DIR__)); $loader->register(); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(VENDOR_PATH . '/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(VENDOR_PATH . '/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php'); Gedmo\DoctrineExtensions::registerAnnotations(); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache()); $_ENV['annotation_reader'] = $reader;
<?php // Some paths define('TESTS_BASEDIR', realpath(__DIR__)); define('LIBRARY_PATH', realpath(TESTS_BASEDIR . '/../library')); define('VENDOR_PATH', realpath(TESTS_BASEDIR . '/../vendor')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array(LIBRARY_PATH, VENDOR_PATH, get_include_path()))); // Load the Composer autoloader and point it at BedREST require_once VENDOR_PATH . '/autoload.php'; $loader = new Composer\Autoload\ClassLoader(); $loader->add('BedRest\\TestFixtures', TESTS_BASEDIR); $loader->add('BedRest\\Tests', TESTS_BASEDIR); $loader->add('BedRest', LIBRARY_PATH); $loader->register(); // register custom annotations Doctrine\Common\Annotations\AnnotationRegistry::registerFile(VENDOR_PATH . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(VENDOR_PATH . '/bedrest/bedrest/library/BedRest/Resource/Mapping/Annotations.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(VENDOR_PATH . '/bedrest/bedrest/library/BedRest/Service/Mapping/Annotations.php');
<?php require __DIR__ . '/../vendor/autoload.php'; $namespaces = (include __DIR__ . '/../vendor/composer/autoload_namespaces.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces); Carpenter\Configuration::$factoryPaths = [__DIR__];
<?php define('TESTS_TEMP_DIR', '/tmp'); define('VENDOR_PATH', realpath(__DIR__ . '/../vendor')); $loader = (require __DIR__ . '/../vendor/autoload.php'); $loader->add('AshleyDawson\\DoctrineGaufretteStorableBundle\\Tests', __DIR__); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(VENDOR_PATH . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); // todo: implement Mongo ODM support //Doctrine\Common\Annotations\AnnotationRegistry::registerFile( // VENDOR_PATH.'/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php' //); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache()); $_ENV['annotation_reader'] = $reader;
public function initialize() { Doctrine\Common\Annotations\AnnotationRegistry::registerLoader("class_exists"); date_default_timezone_set('Europe/Prague'); $this->getService('events.manager')->createEvent(array('Nette\\DI\\Container', 'onInitialize'))->dispatch($this); header('X-Frame-Options: SAMEORIGIN'); header('X-Powered-By: Nette Framework'); header('Content-Type: text/html; charset=utf-8'); Nette\Reflection\AnnotationsParser::setCacheStorage($this->getByType("Nette\\Caching\\IStorage")); Nette\Reflection\AnnotationsParser::$autoRefresh = TRUE; $this->getService('session.session')->exists() && $this->getService('session.session')->start(); Kdyby\Doctrine\Diagnostics\Panel::registerBluescreen($this); Tracy\Debugger::getBlueScreen()->collapsePaths[] = '/home/richmond/vhosts/nette-test/sandbox/vendor/kdyby/doctrine/src/Kdyby/Doctrine'; Tracy\Debugger::getBlueScreen()->collapsePaths[] = '/home/richmond/vhosts/nette-test/sandbox/vendor/doctrine'; Tracy\Debugger::getBlueScreen()->collapsePaths[] = '/home/richmond/vhosts/nette-test/sandbox/app/../temp/proxies'; }
public function _initDoctrine() { $event = $this->profiler->startEvent('Init library: Doctrine'); $loader = new Doctrine\Common\ClassLoader('Entity', $this->config->db->doctrine->entity); $loader->register(); $loader = new Doctrine\Common\ClassLoader('EntityProxy', $this->config->db->doctrine->entityProxy); $loader->register(); $config = new Doctrine\ORM\Configuration(); $cache = new Doctrine\Common\Cache\ArrayCache(); $config->setQueryCacheImpl($cache); $config->setProxyDir($this->config->db->doctrine->entityProxy); $config->setProxyNamespace('EntityProxy'); $config->setAutoGenerateProxyClasses(true); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(LIBRARY_PATH . '/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); $driver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver(new Doctrine\Common\Annotations\AnnotationReader(), array($this->config->db->doctrine->entity)); $config->setMetadataDriverImpl($driver); $config->setMetadataCacheImpl($cache); $em = Doctrine\ORM\EntityManager::create($this->config->db->params->toArray(), $config); Yaf\Registry::set('entityManager', $em); $this->profiler->endEvent($event); }
public function getClosures() { return ['__anonymous__3f09_123574_1415963578543' => ['constructor' => [1 => function (ContainerInterface $container) { if (trim($_SERVER['REQUEST_URI'], '/') == trim(ROOT_URL, '/')) { return "#about"; } else { return ROOT_URL . "#about"; } }]], '__anonymous__3f09_325259_1415963587939' => ['constructor' => [1 => function (ContainerInterface $container) { if (trim($_SERVER['REQUEST_URI'], '/') == trim(ROOT_URL, '/')) { return "#team"; } else { return ROOT_URL . "#team"; } }]], '__anonymous__3f09_447968_1415963567295' => ['constructor' => [1 => function (ContainerInterface $container) { if (trim($_SERVER['REQUEST_URI'], '/') == trim(ROOT_URL, '/')) { return "#feedback"; } else { return ROOT_URL . "#feedback"; } }]], '__anonymous__3f09_796349_1416051015274' => ['constructor' => [1 => function (ContainerInterface $container) { if (trim($_SERVER['REQUEST_URI'], '/') == trim(ROOT_URL, '/')) { return "#api"; } else { return ROOT_URL . "#api"; } }]], '__anonymous__3f09_867472_1415899120049' => ['constructor' => [1 => function (ContainerInterface $container) { if (trim($_SERVER['REQUEST_URI'], '/') == trim(ROOT_URL, '/')) { return "#search"; } else { return ROOT_URL . "#search"; } }]], 'annotationReader' => function (ContainerInterface $container) { // Using composer autoloader $loader = (require ROOT_PATH . 'vendor/autoload.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass')); // Creating a new AnnotationReader $reader = new Doctrine\Common\Annotations\AnnotationReader(); return new Doctrine\Common\Annotations\CachedReader($reader, new Doctrine\Common\Cache\ArrayCache()); }, 'colorLogger' => ['constructor' => [0 => function (ContainerInterface $container) { return array('colors' => array('debug' => "[0;35m", 'error' => "[1;31m", 'section' => "[1;37m", 'subsection' => "[1;33m", 'ok' => "[1;32m")); }]], 'elasticSearchClient' => ['constructor' => [0 => function (ContainerInterface $container) { return ['hosts' => [ELASTICSEARCH_HOST . ':' . ELASTICSEARCH_PORT]]; }]], 'mongoClient' => function (ContainerInterface $container) { return new \MongoClient(MONGODB_CONNECTIONSTRING); }, 'mongoItemsCollection' => function (ContainerInterface $container) { return $container->get('mongoPackanalystDb')->items; }, 'mongoPackagesCollection' => function (ContainerInterface $container) { return $container->get('mongoPackanalystDb')->packages; }, 'mongoPackanalystDb' => function (ContainerInterface $container) { return $container->get('mongoClient')->packanalyst; }]; }
$loader->register(); $loader = new ClassLoader('Doctrine\\DBAL', $vendorPath . '/doctrine-dbal/lib'); $loader->register(); $loader = new ClassLoader('Doctrine\\ORM', $vendorPath . '/doctrine-orm/lib'); $loader->register(); // gedmo extensions $loader = new ClassLoader('Gedmo', $gedmoPath); $loader->register(); // if you use yaml, you need a yaml parser, same as command line tool $loader = new ClassLoader('Symfony', $vendorPath); $loader->register(); // autoloader for Entity namespace $loader = new ClassLoader('Entity', __DIR__ . '/app'); $loader->register(); // ensure standard doctrine annotations are registered Doctrine\Common\Annotations\AnnotationRegistry::registerFile($vendorPath . '/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); // Second configure ORM // globally used cache driver, in production use APC or memcached $cache = new Doctrine\Common\Cache\ArrayCache(); // standard annotation reader $annotationReader = new Doctrine\Common\Annotations\AnnotationReader(); $cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader($annotationReader, $cache); // create a driver chain for metadata reading $driverChain = new Doctrine\ORM\Mapping\Driver\DriverChain(); // load superclass metadata mapping only, into driver chain // also registers Gedmo annotations.NOTE: you can personalize it Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $cachedAnnotationReader); // now we want to register our application entities, // for that we need another metadata driver used for Entity namespace $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, array(__DIR__ . '/app/Entity')); // NOTE: driver for application Entity can be different, Yaml, Xml or whatever
private static function newConnect() { $dir = __DIR__ . '/../../libs/Doctrine/'; $vendorPath = realpath($dir); $ExtensionPath = realpath($dir . '/DoctrineExtensions'); require_once $vendorPath . '/Doctrine/Common/ClassLoader.php'; // autoload all vendors $loader = new Doctrine\Common\ClassLoader('Doctrine\\Common', $vendorPath); $loader->register(); $loader = new Doctrine\Common\ClassLoader('Doctrine\\DBAL', $vendorPath); $loader->register(); $loader = new Doctrine\Common\ClassLoader('Doctrine\\ORM', $vendorPath); $loader->register(); // gedmo extensions $loader = new Doctrine\Common\ClassLoader('Gedmo', $ExtensionPath); $loader->register(); // Pagefanta $classLoader = new Doctrine\Common\ClassLoader("Pagerfanta", $ExtensionPath); $classLoader->register(); //MYSQL Functions $classLoader = new \Doctrine\Common\ClassLoader('DoctrineExtensions', realpath($dir)); $classLoader->register(); // autoloader for Entity namespace $loader = new Doctrine\Common\ClassLoader('Entities', $dir); $loader->register(); // ensure standard doctrine annotations are registered Doctrine\Common\Annotations\AnnotationRegistry::registerFile($vendorPath . '/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); // Second configure ORM // globally used cache driver $cache = new Doctrine\Common\Cache\ArrayCache(); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Gedmo\\Mapping\\Annotation', $ExtensionPath); $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain(); $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array($dir . 'Entities', $ExtensionPath . '/Gedmo/Tree/Entity')); // drivers $driverChain->addDriver($annotationDriver, 'Gedmo\\Tree\\Entity'); $driverChain->addDriver($annotationDriver, 'Entities'); // general ORM configuration $config = new Doctrine\ORM\Configuration(); //$config->setProxyDir(sys_get_temp_dir()); $config->setProxyDir($dir . '/Proxies'); $config->setProxyNamespace('Proxy'); $config->setAutoGenerateProxyClasses(true); // this can be based on production config. FALSE // register metadata driver $config->setMetadataDriverImpl($driverChain); // use our allready initialized cache driver $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // Third, create event manager and hook prefered extension listeners $evm = new Doctrine\Common\EventManager(); // gedmo extension listeners // tree $treeListener = new Gedmo\Tree\TreeListener(); $treeListener->setAnnotationReader($reader); $evm->addEventSubscriber($treeListener); // timestampable $timestampableListener = new Gedmo\Timestampable\TimestampableListener(); $timestampableListener->setAnnotationReader($reader); $evm->addEventSubscriber($timestampableListener); // mysql set names UTF-8 if required $evm->addEventSubscriber(new Doctrine\DBAL\Event\Listeners\MysqlSessionInit()); // Finally, create entity manager $connection = array('dbname' => DB_DATABASE, 'user' => DB_USER, 'password' => DB_PASSWORD, 'host' => DB_HOST, 'driver' => 'pdo_mysql'); $config->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\\Query\\Mysql\\Year'); $config->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\\Query\\Mysql\\Month'); $config->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\\Query\\Mysql\\Day'); $config->addCustomDatetimeFunction('HOUR', 'DoctrineExtensions\\Query\\Mysql\\Hour'); $config->addCustomDatetimeFunction('DATE', 'DoctrineExtensions\\Query\\Mysql\\Date'); $config->addCustomDatetimeFunction('DATEDIFF', 'DoctrineExtensions\\Query\\MySql\\DateDiff'); try { $em = Doctrine\ORM\EntityManager::create($connection, $config, $evm); } catch (Exception $e) { } self::$EntityManager = $em; }
<?php // Tests/bootstrap.php $loader = @(include __DIR__ . '/../vendor/.composer/autoload.php'); if (!$loader) { die(<<<'EOT' You must set up the project dependencies, run the following commands: wget http://getcomposer.org/composer.phar php composer.phar install EOT ); } use Doctrine\Common\ClassLoader; $classLoader = new ClassLoader('Doctrine\\Tests', __DIR__ . '/../tests'); $classLoader->register(); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Doctrine\\ODM\\CouchDB\\Mapping\\Annotations', __DIR__ . '/../lib');
| Next, we need to bind some important interfaces into the container so | we will be able to resolve them when needed. The kernels serve the | incoming requests to this application from both the web and CLI. | */ $app->singleton(Illuminate\Contracts\Http\Kernel::class, KevinDierkx\Muse\Http\Kernel::class); $app->singleton(Illuminate\Contracts\Console\Kernel::class, KevinDierkx\Muse\Console\Kernel::class); $app->singleton(Illuminate\Contracts\Debug\ExceptionHandler::class, KevinDierkx\Muse\Exceptions\Handler::class); /* |-------------------------------------------------------------------------- | Register annotation loader |-------------------------------------------------------------------------- | | Doctrine Annotations does not use normal PHP autoloading, therefore | we are required to register the autoloader separately. | | More information: http://stackoverflow.com/a/14646475 | */ Doctrine\Common\Annotations\AnnotationRegistry::registerLoader([require base_path('vendor/autoload.php'), 'loadClass']); /* |-------------------------------------------------------------------------- | Return The Application |-------------------------------------------------------------------------- | | This script returns the application instance. The instance is given to | the calling script so we can separate the building of the instances | from the actual running of the application and sending responses. | */ return $app;
<?php $vendorDir = __DIR__ . '/../vendor'; $bundleDir = __DIR__ . '/../vendor/bundles'; require $vendorDir . '/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; $loader = new Symfony\Component\ClassLoader\ApcUniversalClassLoader('lichess.cl.'); $loader->registerNamespaces(array('Symfony' => array($vendorDir . '/symfony/src', $bundleDir), 'Doctrine\\MongoDB' => $vendorDir . '/doctrine-mongodb/lib', 'Doctrine\\ODM\\MongoDB' => $vendorDir . '/doctrine-mongodb-odm/lib', 'Doctrine\\Common\\DataFixtures' => $vendorDir . '/doctrine-data-fixtures/lib', 'Doctrine\\Common' => $vendorDir . '/doctrine-common/lib', 'Zend' => $vendorDir . '/zend-subtrees', 'Monolog' => $vendorDir . '/monolog/src', 'Assetic' => $vendorDir . '/assetic/src', 'Pagerfanta' => $vendorDir . '/pagerfanta/src', 'Gedmo' => $vendorDir . '/doctrine-extensions/lib', 'EasyCSV' => $vendorDir . '/easy-csv/lib', 'Buzz' => $vendorDir . '/buzz/lib', 'Ornicar' => $bundleDir, 'Sensio' => $bundleDir, 'WhiteOctober' => $bundleDir, 'FOS' => $bundleDir, 'Herzult' => $bundleDir, 'Bundle' => $bundleDir, 'FOQ' => $bundleDir)); $loader->registerPrefixes(array('Twig_' => $vendorDir . '/twig/lib', 'Elastica_' => $vendorDir . '/elastica/lib')); $loader->registerPrefixFallbacks(array(__DIR__ . '/../vendor/symfony/src/Symfony/Component/Locale/Resources/stubs')); $loader->registerNamespaceFallbacks(array(__DIR__ . '/../src')); $loader->register(); // doctrine annotations Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) use($loader) { $loader->loadClass($class); return class_exists($class, false); }); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Annotations/DoctrineAnnotations.php');
/** * Init doctrine method * * @return Shopware\Components\Model\ModelManager */ public function initModels() { /** @var $config \Doctrine\ORM\Configuration */ $config = $this->getResource('ModelConfig'); $cacheResource = $this->getResource('Cache'); // Check if native Doctrine ApcCache may be used if ($cacheResource->getBackend() instanceof Zend_Cache_Backend_Apc) { $cache = new Doctrine\Common\Cache\ApcCache(); } else { $cache = new Shopware\Components\Model\Cache($cacheResource); } // register standard doctrine annotations Doctrine\Common\Annotations\AnnotationRegistry::registerFile( 'Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' ); // register symfony validation annotions Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace( 'Symfony\Component\Validator\Constraint' ); // register gedmo annotions Doctrine\Common\Annotations\AnnotationRegistry::registerFile( 'Gedmo/Mapping/Annotation/All.php' ); $cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader( new Doctrine\Common\Annotations\AnnotationReader, $cache ); $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver( $cachedAnnotationReader, array( $this->Application()->Loader()->isReadable('Gedmo/Tree/Entity/MappedSuperclass'), $this->Application()->AppPath('Models') )); // create a driver chain for metadata reading $driverChain = new Doctrine\ORM\Mapping\Driver\DriverChain(); // register annotation driver for our application $driverChain->addDriver($annotationDriver, 'Gedmo'); $driverChain->addDriver($annotationDriver, 'Shopware\\Models\\'); $driverChain->addDriver($annotationDriver, 'Shopware\\CustomModels\\'); $this->registerResource('ModelAnnotations', $annotationDriver); $config->setMetadataDriverImpl($driverChain); // Create event Manager $eventManager = new \Doctrine\Common\EventManager(); $treeListener = new Gedmo\Tree\TreeListener; $treeListener->setAnnotationReader($cachedAnnotationReader); $eventManager->addEventSubscriber($treeListener); // Create new shopware event subscriber to handle the entity lifecycle events. $liveCycleSubscriber = new \Shopware\Components\Model\EventSubscriber( $this->Application()->Events() ); $eventManager->addEventSubscriber($liveCycleSubscriber); // now create the entity manager and use the connection // settings we defined in our application.ini $conn = \Doctrine\DBAL\DriverManager::getConnection( array('pdo' => $this->Application()->Db()->getConnection()), $config, $eventManager ); $entityManager = Shopware\Components\Model\ModelManager::create($conn, $config, $eventManager); //if (!is_readable(rtrim($config->getProxyDir(), '/') . '/__CG__ShopwareModelsShopShop.php')) { // $metadata = $entityManager->getMetadataFactory()->getAllMetadata(); // $proxyFactory = $entityManager->getProxyFactory(); // $proxyFactory->generateProxyClasses($metadata); //} return $entityManager; }
<?php $loader = (require_once __DIR__ . '/../vendor/autoload.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . '/../vendor/jms/serializer/src'); $app = new Domora\TvGuide\Application(); umask(00); $app->loadRoutes(); $app->run();
public function initialize() { Doctrine\Common\Annotations\AnnotationRegistry::registerLoader("class_exists"); date_default_timezone_set('Europe/Prague'); Nette\Reflection\AnnotationsParser::setCacheStorage($this->getByType("Nette\\Caching\\IStorage")); Nette\Reflection\AnnotationsParser::$autoRefresh = FALSE; $this->getService('events.manager')->createEvent(array('Nette\\DI\\Container', 'onInitialize'))->dispatch($this); Kdyby\Doctrine\Diagnostics\Panel::registerBluescreen($this); Tracy\Debugger::getBlueScreen()->collapsePaths[] = '/home/richmond/vhosts/nette-test/sandbox/vendor/kdyby/doctrine/src/Kdyby/Doctrine'; Tracy\Debugger::getBlueScreen()->collapsePaths[] = '/home/richmond/vhosts/nette-test/sandbox/vendor/doctrine'; Tracy\Debugger::getBlueScreen()->collapsePaths[] = '/home/richmond/vhosts/nette-test/sandbox/app/../temp/proxies'; }
* versions. Regarding AnnotationDriver setup it most probably will be changed into * xml. Because annotation driver fails to read other classes in same namespace */ // connection args, modify at will $connection = array('host' => '127.0.0.1', 'port' => 3306, 'user' => 'root', 'password' => null, 'dbname' => 'test', 'driver' => 'pdo_mysql'); if (!file_exists(__DIR__ . '/../vendor/autoload.php')) { die('cannot find vendors, read README.md how to use composer'); } // First of all autoloading of vendors $loader = (require __DIR__ . '/../vendor/autoload.php'); // gedmo extensions $loader->add('Gedmo', __DIR__ . '/../lib'); // autoloader for Entity namespace $loader->add('Entity', __DIR__ . '/app'); // ensure standard doctrine annotations are registered Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); // Second configure ORM // globally used cache driver, in production use APC or memcached $cache = new Doctrine\Common\Cache\ArrayCache(); // standard annotation reader $annotationReader = new Doctrine\Common\Annotations\AnnotationReader(); $cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader($annotationReader, $cache); // create a driver chain for metadata reading $driverChain = new Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain(); // load superclass metadata mapping only, into driver chain // also registers Gedmo annotations.NOTE: you can personalize it Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $cachedAnnotationReader); // now we want to register our application entities, // for that we need another metadata driver used for Entity namespace $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, array(__DIR__ . '/app/Entity')); // NOTE: driver for application Entity can be different, Yaml, Xml or whatever
if (file_exists($file = $_SERVER['DOCTRINE_FIXTURES'] . '/lib/' . str_replace('\\', '/', $class) . '.php')) { require_once $file; } } if (isset($_SERVER['DOCTRINE_COMMON']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\\Common')) { if (file_exists($file = $_SERVER['DOCTRINE_COMMON'] . '/lib/' . str_replace('\\', '/', $class) . '.php')) { require_once $file; } } if (isset($_SERVER['DOCTRINE_DBAL']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\\DBAL')) { if (file_exists($file = $_SERVER['DOCTRINE_DBAL'] . '/lib/' . str_replace('\\', '/', $class) . '.php')) { require_once $file; } } if (isset($_SERVER['DOCTRINE_ORM']) && 0 === strpos(ltrim($class, '/'), 'Doctrine\\ORM')) { if (file_exists($file = $_SERVER['DOCTRINE_ORM'] . '/lib/' . str_replace('\\', '/', $class) . '.php')) { require_once $file; } } if (0 === strpos(ltrim($class, '/'), 'Symfony\\Bridge\\Doctrine')) { if (file_exists($file = __DIR__ . '/../' . substr(str_replace('\\', '/', $class), strlen('Symfony\\Bridge\\Doctrine')) . '.php')) { require_once $file; } } }); if (isset($_SERVER['DOCTRINE_COMMON'])) { Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) use($loader) { $loader($class); return class_exists($class, false); }); }
<?php require_once __DIR__ . "/../../../../vendor/autoload.php"; // register annotations of jms serializer and doctrine Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . '/../../../../vendor/jms/serializer/src'); Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace('Doctrine\\Search\\Mapping\\Annotations', __DIR__ . '/../vendor/doctrine/search/lib');
<?php // Some paths define('TESTS_BASEDIR', realpath(__DIR__)); define('LIBRARY_PATH', realpath(TESTS_BASEDIR . '/../library')); define('VENDOR_PATH', realpath(TESTS_BASEDIR . '/../vendor')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array(LIBRARY_PATH, VENDOR_PATH, get_include_path()))); // Load the Composer autoloader and point it at the BedREST namespaces require_once VENDOR_PATH . '/autoload.php'; $loader = new Composer\Autoload\ClassLoader(); $loader->add('BedRest\\TestFixtures', TESTS_BASEDIR); $loader->add('BedRest\\Tests', TESTS_BASEDIR); $loader->add('BedRest', LIBRARY_PATH); $loader->register(); // register custom annotations Doctrine\Common\Annotations\AnnotationRegistry::registerFile(LIBRARY_PATH . '/BedRest/Resource/Mapping/Annotations.php'); Doctrine\Common\Annotations\AnnotationRegistry::registerFile(LIBRARY_PATH . '/BedRest/Service/Mapping/Annotations.php');