-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Adding the Doctorine CLI to Silex Console App #11
Comments
@bassettsj 12-17: https://github.com/dominikzogg/silexskeleton/blob/master/app/console#L12 I uses my manager registry (https://github.com/dominikzogg/doctrine-orm-manager-registry-provider), without you need to replace $app['doctrine']->getConnection() with $app['db'] and $app['doctrine']->getManager() with $app['em'] |
I used Silex Kitchen Edition as well and added the following to src/console.php: $em = $app['orm.em'];
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
$console->setHelperSet($helperSet);
$console->addCommands(array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
)); Works like a charm! |
Take a look @ https://github.com/marcojanssen/silex-rest in app/console.php i added: /*
* Doctrine CLI
*/
$helperSet = new HelperSet(array(
'db' => new ConnectionHelper($app['orm.em']->getConnection()),
'em' => new EntityManagerHelper($app['orm.em'])
));
$console->setHelperSet($helperSet);
Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($console); |
https://github.com/saxulum/saxulum-doctrine-orm-manager-registry-provider this way you get fully wupport for all entity managers (if there are many) |
Thanks @marcojanssen, clean solution worked perfectly 👍 |
@erikaheidi this is probably the most poerfull way in silex atm: https://github.com/saxulum/saxulum-doctrine-orm-manager-registry-provider#doctrine-orm-console |
First of all thanks for putting this out there @dflydev. I am lost as to adding the Doctrine CLI functions to my applications console to be able to create the Doctrine schema. I am using lyrixx/Silex-Kitchen-Edition to structure the application. They have already included a nice symfony/Console component, so my question is how I can integration the Doctrine ORM Service provider there to be able to handle generating the entity tabels.
The text was updated successfully, but these errors were encountered: