Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 2.76 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. // Define path to application directory
  4. defined('APPLICATION_PATH')
  5.     || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
  6.  
  7. // Define application environment
  8. defined('APPLICATION_ENV')
  9.     || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'default'));
  10.  
  11. // Ensure library/ is on include_path
  12. set_include_path(implode(PATH_SEPARATOR, array(
  13.     realpath(APPLICATION_PATH . '/../library'),
  14.     get_include_path(),
  15. )));
  16.  
  17. /** Zend_Application */
  18. require_once 'Zend/Application.php';
  19. require_once 'FMM/Application/ConfigLoader.php';
  20.  
  21. $config = \FMM\Application\ConfigLoader::loadConfig();
  22.  
  23. // Create application, bootstrap, and run
  24. $application = new Zend_Application(
  25.     APPLICATION_ENV,
  26.     $config
  27. );
  28. $bootstrap = $application->bootstrap()->getBootstrap();
  29.  
  30. $bootstrap->bootstrap('Config')
  31.           ->bootstrap('Doctrine');
  32.  
  33. $autoloader = \Zend_Loader_Autoloader::getInstance();
  34. $classLoader = new \Doctrine\Common\ClassLoader('Symfony', APPLICATION_PATH . '/../library/vendor');
  35. $autoloader->pushAutoloader(array($classLoader, 'loadClass'), 'Symfony');
  36.  
  37. $em = $application->getBootstrap()->getResource('doctrine');
  38.  
  39. $helperSet = new \Symfony\Components\Console\Helper\HelperSet(array(
  40.     'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
  41.     'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
  42. ));
  43.  
  44.  
  45. $cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
  46. $cli->setCatchExceptions(true);
  47. $cli->setHelperSet($helperSet);
  48. $cli->addCommands(array(
  49.     // DBAL Commands
  50.     new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
  51.     new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
  52.  
  53.     // ORM Commands
  54.     new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
  55.     new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
  56.     new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
  57.     new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
  58.     new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
  59.     new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
  60.     new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
  61.     new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
  62.     new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
  63.     new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
  64.     new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
  65.     new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
  66.     new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
  67.  
  68. ));
  69. $cli->run();