Kohana 3 Command line output buffering?

Cra*_*oto 5 php kohana kohana-3

I am using Kohana 3 and I have a controller that extends Kohana_Controller. I call it from the command line using:

php /path/to//index.php --uri="url/path"
Run Code Online (Sandbox Code Playgroud)

It works just fine, but this particular script takes a long time and during the execution I am echoing status messages (echo 'status message';) but none of the messages appear until after the script has completed executing.

I want to see the status messages as they are echoed, can anyone tell me how to do it?

Thanks

Dar*_*ein 8

它看起来像Kohana :: init()(可能在你的bootsrap中调用)调用ob_start().这意味着在该点之后输出的所有内容都包含在输出缓冲区中.要停止此操作,请在Controller中的before方法中添加ob_end_flush()输出可能已输出的任何内容并关闭输出缓冲.在此之后你应该立即输出任何回声.

所以你的代码看起来像:

  Controller_CLI extends Controller {
       public function before() {
              // empty the output buffre
              ob_end_flush();

              // call parent before() just incase there's anything 
              // in the parent before that you need/want to execute
              parent::before();
       }
  }
Run Code Online (Sandbox Code Playgroud)