我需要动态地将路由添加到我的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\...
我的文件已修改但未添加新的更改:(
答案 0 :(得分:1)
我不认为这是个好主意,如果你想让动态路由使用Zend_Controller_Router_Route和动态部分。