cli-config.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. require_once '../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
  3. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/../../lib'));
  4. $classLoader->register();
  5. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib'));
  6. $classLoader->register();
  7. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib'));
  8. $classLoader->register();
  9. $classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor'));
  10. $classLoader->register();
  11. $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
  12. $classLoader->register();
  13. $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
  14. $classLoader->register();
  15. $config = new \Doctrine\ORM\Configuration();
  16. $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
  17. $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
  18. $config->setMetadataDriverImpl($driverImpl);
  19. $config->setProxyDir(__DIR__ . '/Proxies');
  20. $config->setProxyNamespace('Proxies');
  21. $connectionOptions = array(
  22. 'driver' => 'pdo_sqlite',
  23. 'path' => 'database.sqlite'
  24. );
  25. $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
  26. $helpers = new Symfony\Component\Console\Helper\HelperSet(array(
  27. 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
  28. 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
  29. ));