我需要动态地将路由添加到我的 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\...
我的文件已修改但未添加新更改:(