Zend_Controllerの履歴

とりあえず動かす

<?php
// main
$ctrl = Zend_Controller_Front::getInstance();
$ctrl->setControllerDirectory('app/controllers');
$ctrl->dispatch();

// app/controllers/IndexController.php
class IndexController extends Zend_Controller_Action{
    public function indexAction(){
        $this->view->assign('time', time());
    }
}
// app/controllers/ErrorController.php
class ErrorController extends Zend_Controller_Action{
    public function errorAction(){
    }
}
// app/views/scripts/index/index.phtmlと
// app/views/scripts/error/error.phtmlも用意しておく

//
?>

エラーを捕捉したい場合

<?php
$ctrl->dispatch();
$exceptions = $ctrl->getResponse()->getException();
if ($exceptions){
    var_dump(array_shift($exceptions));
}
?>

テンプレートにassignして、出力する

<?php
function hogeAction(){
  $this->view->assign('time', time();
}
?>
// app/views/scripts/index/hoge.phtml
/*
<html>
  <body>
    now: <?php echo $this->view->time ?>
  </body>
</html>
 */


Zend_Controller_Action

初期化はinit()に書く
$this->viewにデフォルトのViewが入ってる。