Bonjour je cherche à créer une commande symfony2 me permettant de régénerer toute ma base de donner et d'ajouter mes fixtures.
mon code est le suivant:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$commands = array();
$arguments = array();
$commands []= $this->getApplication()->find('doctrine:database:drop');
$arguments []= array('command'=>'doctrine:database:drop','--force'=>true);
$commands []= $this->getApplication()->find('cache:clear');
$arguments []= array('command'=>'cache:clear');
$commands []= $this->getApplication()->find('generate:doctrine:entities');
$arguments []= array('command'=>'generate:doctrine:entities','name'=>'Acme');
$commands []= $this->getApplication()->find('doctrine:database:create');
$arguments []= array('command'=>'doctrine:database:create');
$commands []= $this->getApplication()->find('doctrine:schema:create');
$arguments []= array('command'=>'doctrine:schema:create');
$commands []= $this->getApplication()->find('doctrine:fixtures:load');
$arguments []= array('command'=>'doctrine:fixtures:load');
foreach($commands as $key => $command)
{
$input = new ArrayInput($arguments[$key]);
$returnCode = $command->run($input, $output);
}
$output->writeln("The whole website has been regenerated");
} |
Tout marche très bien sauf lors de l'execution de la commande:
php app/console doctrine:schema:create
où je reçois l'erreur
1 2 3 4 5 6
| Creating database schema...
[PDOException]
SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected |
Par contre si j'execute toutes ces commandes une par une dans la console tout marche.
De même si j'utilise ma commande personnalisée et qu'après lorsque cela plante, je relance manuellement la commande
php app/console doctrine:schema:create
tout se passe bien...
Merci de votre aide
John
Partager