doctrine.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. require_once 'Doctrine/Common/ClassLoader.php';
  3. $classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
  4. $classLoader->register();
  5. $classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
  6. $classLoader->register();
  7. $configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
  8. $helperSet = null;
  9. if (file_exists($configFile)) {
  10. if ( ! is_readable($configFile)) {
  11. trigger_error(
  12. 'Configuration file [' . $configFile . '] does not have read permission.', E_ERROR
  13. );
  14. }
  15. require $configFile;
  16. foreach ($GLOBALS as $helperSetCandidate) {
  17. if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
  18. $helperSet = $helperSetCandidate;
  19. break;
  20. }
  21. }
  22. }
  23. $helperSet = ($helperSet) ?: new \Symfony\Component\Console\Helper\HelperSet();
  24. $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\DBAL\Version::VERSION);
  25. $cli->setCatchExceptions(true);
  26. $cli->setHelperSet($helperSet);
  27. $cli->addCommands(array(
  28. // DBAL Commands
  29. new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
  30. new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
  31. ));
  32. $cli->run();