Kohana 3 命令行输出缓冲?
我正在使用 Kohana 3,并且有一个扩展 Kohana_Controller 的控制器。我使用以下命令从命令行调用它:
php /path/to//index.php --uri="url/path"
它工作得很好,但是这个特定的脚本需要很长时间,并且在执行期间我正在回显状态消息(回显“状态消息”;),但直到脚本执行完毕后才会出现任何消息执行完成。
我想查看回显的状态消息,有人可以告诉我该怎么做吗?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 Kohana::init() (可能在您的 bootsrap 中调用)调用了
ob_start()
。这意味着该点之后的所有输出都包含在输出缓冲区中。要阻止这种情况,请在控制器的 before 方法中添加 ob_end_flush() 来输出可能已输出的任何内容并关闭输出缓冲。之后您发出的任何回声都应该立即输出。所以你的代码看起来像:
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 addob_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: