since 2011-02-03
PHP のアプリケーションフレームワークの一つ。
ZendFramework-1.11.3-minimal によると PHP 5.2.4 以降が必要。
RewriteEngine On RewriteRule !\.(js|ico|gif|jpg|png|css|zip|gz)$ index.php RewriteBase /zendframework/ZendApp DirectoryIndex index.php
apache の rewrite を使用する。
最初のルールは拡張子がパターンに当てはまらないものを index.php に書き換える。
<?php set_include_path('c:/htdocs/zendframework/library'); require_once 'Zend/Controller/Front.php'; Zend_Controller_Front::run('controllers'); //require_once 'Zend/Version.php'; //echo Zend_Version::VERSION;
下の2行を有効にすると localhost/zendframework/ZendApp/index で 1.11.3 という出力が得られた。
<?php require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $req = $this->getRequest(); $co = $req->getControllerName(); $ac = $req->getActionName(); $this->view->assign('day', $req->getParam('day') ); $this->view->assign('co', $co); $this->view->assign('ac', $ac); $this->view->assign('val', '<12345>'); echo $this->render(); } }
<pre> <?php echo 'hello' . PHP_EOL; echo $this->escape( $this->val ) . PHP_EOL; echo $this->escape( $this->co ) . PHP_EOL; echo $this->escape( $this->ac ) . PHP_EOL; echo $this->escape( $this->day ) . PHP_EOL; ?> </pre>
localhost/zendframework/ZendApp/index/index/day/25
を叩くと
hello <12345> index index 25
が得られた。