2017-12-12 21 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.'); 
    } 
} 

문제는 때 반복 시작을 발생합니다. 실제로 세 줄 대신 첫 줄의 명령 만 실행됩니다. 어떤 이유에서든 첫 번째 명령을 실행 한 후에 반복이 멈춘 것처럼 보입니다. 실제로 이해할 수 없지만 실제로는 끝에있는 $output->writeln의 메서드가 호출되지 않습니다.

답변

0

콘솔의 디버그를 활성화하여 문제를 이해해야합니다.

콘솔 명령은 기본적으로 deven 인 .env 파일의 APP_ENV 변수에 정의 된 환경에서 실행됩니다. 또한 "디버그"모드를 켜거나 끄기 위해 APP_DEBUG 값을 읽습니다 (기본값은 1로 설정 됨).

다른 환경 또는 디버그 모드에서 명령을 실행하려면 APP_ENV 및 APP_DEBUG 값을 편집하십시오.