0

我需要动态地将路由添加到我的 routes.ini 文件中。下面是我的代码。

$appConfigPath = APPLICATION_PATH . '/configs/routes.ini';
$appConfig     = new Zend_Config_Ini($appConfigPath, null,  array('skipExtends' => true,'allowModifications' => true));

$controller = "foo"; $routeName = "bar"; $action = "tar";

$appConfig->production->routes->$routeName->type = "Zend_Controller_Router_Route";
$appConfig->production->routes->$routeName->route = $routeName;
$appConfig->production->routes->$routeName->defaults->controller = $controller;
$appConfig->production->routes->$routeName->defaults->action     =  $action;
$appConfig->production->routes->$routeName->reverse =  $routeName;

$writer = new Zend_Config_Writer_Ini();
$writer->setConfig($appConfig)->setFilename($appConfigPath)->write();

但这给了我

Notice: Indirect modification of overloaded property Zend_Config::$bar has no effect in D:\projects\...

Strict Standards: Creating default object from empty value in D:\projects\...

我的文件已修改但未添加新更改:(

4

1 回答 1

1

我不认为这是一个好主意,如果你想要动态路由使用 Zend_Controller_Router_Route 和动态部分。

于 2013-05-21T12:38:33.627 回答