Zend アプリケーションのワークフローを理解しようとしています。私が定義したテストの場合:
コントローラー - IndexController.php:
public function preDispatch() {
error_log('IndexController::preDispatch');
echo 'IndexController::preDispatch <br />'; }
public function init() {
error_log('IndexController::init');
echo 'IndexController::init <br />'; }
public function indexAction() {
error_log('IndexController::indexAction');
echo 'IndexController::indexAction <br />'; }
スクリプトを表示 - index.phtml:
<?php
echo'index view script - echo';
$this->title = "ZF Tutorial";
$this->headTitle($this->title); ?>
<h3>index view script - content</h3>
レイアウト スクリプト - layout.phtml
...
<body>
<div id="content">
<?php
error_log('Layout1');
echo $this->layout()->content ?>
<h1>
<?php
error_log('Layout2');
echo $this->escape($this->title); ?>
</h1>
</div>
</body>
...
そして、ここに私の混乱があります。error_log 出力の順序は、ブラウザーで取得したものとは異なります。
error_log 出力 (予想される順序):
- IndexController::init
- IndexController::preDispatch
- IndexController::indexAction
- レイアウト1
- レイアウト2
ブラウザ出力:
- IndexController::init
- インデックス ビュー スクリプト - エコー
- インデックス ビュー スクリプト - コンテンツ
- IndexController::preDispatch
- IndexController::indexAction
- ZF チュートリアル
ビュースクリプトの後にコントローラの出力がレンダリングされるのはなぜですか? preDispatch と indexAction からのエコー結果は、ビュー スクリプトのコンテンツを最初に出力するために何らかの形でバッファリングされていますか?