console.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. $em = include __DIR__.'/../em.php';
  3. $cli = new Symfony\Component\Console\Application('My CLI interface', '1.0.0');
  4. $cli->setCatchExceptions(true);
  5. // commands
  6. $cli->addCommands(array(
  7. // DBAL Commands
  8. new Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
  9. new Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
  10. // ORM Commands
  11. new Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
  12. new Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
  13. new Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
  14. new Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
  15. new Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
  16. new Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
  17. new Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
  18. new Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
  19. new Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
  20. new Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
  21. new Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
  22. new Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
  23. new Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
  24. new Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
  25. ));
  26. // helpers
  27. $helpers = array(
  28. 'db' => new Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
  29. 'em' => new Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em),
  30. 'dialog' => new Symfony\Component\Console\Helper\DialogHelper(),
  31. );
  32. foreach ($helpers as $name => $helper) {
  33. $cli->getHelperSet()->set($helper, $name);
  34. }
  35. return $cli;