2017-12-12 5 views
0

私は初めてSymfonyでカスタマイズされたコマンドを作成しようとしています。 このコマンドは、3つのコマンドを一度に実行する必要があります。symfonyのカスタマイズされたコマンドは、最初の実行後に停止します

これは、反復の開始時に問題が発生

class DoctrineFullFixturesLoadCommand extends ContainerAwareCommand 
{ 
    protected function configure() 
    { 
     $this 
      ->setName('doctrine:full-fixtures:load') 
      ->setDescription('...') 
      ->addArgument('argument', InputArgument::OPTIONAL, 'Argument description') 
      ->addOption('option', null, InputOption::VALUE_NONE, 'Option description') 
     ; 
    } 

    protected function execute(InputInterface $input, OutputInterface $output) 
    { 
     $argument = $input->getArgument('argument'); 

     if ($input->getOption('option')) { 
      // ... 
     } 

     $arrCommands = [ 
      [ 
       'command' => 'doctrine:database:drop', 
       '--force' => true 
      ], [ 
       'command' => 'doctrine:database:create' 
      ], [ 
       'command' => 'doctrine:schema:update', 
       '--force' => true, 
       '--complete' => true 
      ] 
     ]; 


     foreach ($arrCommands as $arrInput) { 
      $this->getApplication()->run(
       new ArrayInput($arrInput), 
       $output 
      ); 
     } 

     $output->writeln('Command result.'); 
    } 
} 

私のコマンドクラスです。 実際には3行ではなく、行の最初のコマンドだけが実行されます。 何らかの理由で最初のコマンドを実行した後に反復が停止するようですが、実際には最後のメソッド$output->writelnは全く呼び出されません。

答えて

0

コンソールで問題を理解できるように、デバッグを有効にする必要があります。

コンソールコマンドは、デフォルトでdevである.envファイルのAPP_ENV変数で定義された環境で実行されます。また、APP_DEBUG値を読み取って「デバッグ」モードをオンまたはオフにします(デフォルトでは1に設定されています)。

別の環境またはデバッグモードでコマンドを実行するには、APP_ENVおよびAPP_DEBUGの値を編集します。

関連する問題