我有ZF 1,在那裏我工作Bootstrap.php與大量的路由和其他preDispatch的東西。ZendFramework 2 - 我如何做類似ZF1的Bootstrap.php?
但是在ZF2中沒有Bootstrap.php概念了?或者我的意思是我如何在Zf2中做到這一點?
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initPdispatch() {
$this->bootstrap('frontController');
require_once APPLICATION_PATH . '/controllers/plugin/LanguageSelector.php';
$plugin = new LanguageSelector();
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin($plugin);
return $plugin;
}
protected function _initRoutes() {
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$dynamic1 = new Zend_Controller_Router_Route(
'/:variable1',
array(
'controller' => 'router',
),
// array('variable1' => '^[a-zA-Z0-9_-]*$')
array('variable1' => '^[\w.-]*$')
);
$router->addRoute('dynamic1', $dynamic1);
}
Afaik他們強烈推薦**不**使用動態路由了。 – pebbo