ルーティング
- http://framework.zend.com/manual/ja/zend.controller.router.html
- http://codezine.jp/article/detail/2226?p=2
この二つ読んだら出来た.
<?php //index.php $front = Zend_Controller_Front::getInstance(); $router=$front->getRouter(); $router->addRoute( 'test_router', new Zend_Controller_Router_Route( 'test/:id', //ルートの定義 array( //デフォルト値 'controller' => 'test', 'action' => 'index', 'id' => '000' ), array(id' => '\d+') )); Zend_Controller_Front::run('./application/controllers'); ?>
<?php //TestController.phpのindexAction public function indexAction() { $this->view->assign('id', $this->_getParam('id')); } ?>
<?php //view:index.phtml echo $this->escape($this->id); ?>
これで,「http://localhost/test/123」でアクセスすると123って表示される.