2013-11-21 2 views
1

다음 코드를 사용하여 경로 내에서 장인 명령의 출력을 리디렉션합니다.Artisan 출력 버퍼에 모든 출력이 포함되어 있지 않습니다.

use Symfony\Component\Console\Output\BufferedOutput; 

Route::get('/restart', function() 
{ 
    $output = new BufferedOutput; 
    Artisan::call('remote:restart', array(), $output); 
    return $output->fetch(); 
}); 

대부분의 경우 작동합니다. 그러나 SSH 구성 요소를 사용하여 원격 서버에서 일부 작업을 실행하는 명령의 경우 SSH::into()->run()의 결과는 위의 코드에서 무시됩니다. 만 반환)

start 
[[email protected]] (xxxx) Stopping php-fpm: 
[[email protected]] (xxxx) [ OK ] 
[[email protected]] (xxxx) Starting php-fpm: 
[[email protected]] (xxxx) [ OK ] 
[[email protected]] (xxxx) Stopping nginx: 
[[email protected]] (xxxx) [ OK ] 
[[email protected]] (xxxx) Starting nginx: 
[[email protected]] (xxxx) [ OK ] 
end 

그러나 $ 출력 -이> (가져 오기 : 내가 수동으로 장인 명령을 실행하면

, 나는 다음과 같은 출력을 얻을

start end 

답변

4

당신은 출력 인터페이스를 설정해야 그것에 :

use Symfony\Component\Console\Output\BufferedOutput; 

Route::get('/test', function() 
{ 
    $output = new BufferedOutput; 

    SSH::setOutput($output); 

    SSH::run('ls -la'); 

    return $output->fetch(); 
}); 
+0

작동! 제 경우에는 Closure를'SSH :: run()'에 전달하고 클로저 내부의 연결 객체에 대한 display 메소드를 호출하는 것이 더 깔끔합니다. – Dave

관련 문제