Kohana 3 Command line output buffering?
Asked Answered
G

1

5

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"

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

Giverin answered 29/1, 2011 at 22:4 Comment(0)
F
8

It looks like Kohana::init() (likely called in your bootsrap) calls an ob_start(). This means that everything output after that point is contained in the output buffer. To stop this, in your before method in your Controller add ob_end_flush() to output anything that may have already been output and turn off output buffering. Any echo's you make after that should be output immediately.

So your code with look like:

  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();
       }
  }
Familist answered 29/1, 2011 at 22:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.