Advertisement
Guest User

application/cli-config.php

a guest
Oct 5th, 2010
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php
  2. use Doctrine\Common\ClassLoader,
  3.     Doctrine\ORM\Configuration,
  4.     Doctrine\ORM\EntityManager,
  5.     Doctrine\Common\Cache\ArrayCache,
  6.     Doctrine\DBAL\Logging\EchoSqlLogger;
  7.  
  8. define('BASEPATH', __DIR__ . '/../system/');
  9.  
  10. require_once __DIR__ . '/config/database.php';
  11. require_once __DIR__ . '/libraries/Doctrine/Common/ClassLoader.php';
  12.  
  13. $doctrineClassLoader = new ClassLoader('Doctrine',  __DIR__.'libraries');
  14. $doctrineClassLoader->register();
  15. $entitiesClassLoader = new ClassLoader('models', __DIR__);
  16. $entitiesClassLoader->register();
  17. $proxiesClassLoader = new ClassLoader('Proxies', __DIR__.'models/proxies');
  18. $proxiesClassLoader->register();
  19.  
  20. $config = new \Doctrine\ORM\Configuration();
  21. $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
  22. $config->setProxyDir(__DIR__ . '/Proxies');
  23. $config->setProxyNamespace('Proxies');
  24.  
  25. $cache = new ArrayCache;
  26. // Set up driver
  27. $Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
  28. $Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
  29. $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, realpath('../models'));
  30. $config->setMetadataDriverImpl($driver);
  31.  
  32. // Database connection information
  33. $connectionOptions = array(
  34.     'driver' => 'pdo_mysql',
  35.     'user' =>     $db['default']['username'],
  36.     'password' => $db['default']['password'],
  37.     'host' =>     $db['default']['hostname'],
  38.     'dbname' =>   $db['default']['database']
  39. );
  40.  
  41. $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
  42.  
  43. $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
  44.     'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
  45.     'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
  46. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement