タイトル募集中3.0

しがないITソルジャーの雑記。

ルーティング

この二つ読んだら出来た.

<?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って表示される.