2011-01-29 80 views
5

我正在使用Kohana 3,我有一個控制器來擴展Kohana_Controller。 (回聲「狀態消息」;),但沒有一個Kohana 3命令行輸出緩衝?

php /path/to//index.php --uri="url/path" 

它工作得很好,但這個特殊的腳本需要很長的時間和執行過程中,我呼應狀態消息:我使用調用它的命令行消息會一直顯示,直到腳本完成執行。

我想看到狀態消息,因爲它們被回顯,任何人都可以告訴我該怎麼做?

感謝

回答

8

它看起來像的Kohana ::的init()(可能叫你bootsrap)調用的ob_start()。這意味着在該點之後的所有輸出都包含在輸出緩衝區中。要停止此操作,請在控制器的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(); 
     } 
    } 
+0

這個解決我的問題,謝謝 – 2011-01-30 01:01:55