dpy83214 2010-09-12 20:06
浏览 84

为什么在.ini文件中定义的路由不起作用?

In my Bootstrap.php I have the following code which defines a route:

    $router = Zend_Controller_Front::getInstance()->getRouter();

    $router->addRoute('pageDetails', new Zend_Controller_Router_Route('page-details/:uid/:title', array(
        'module'        => 'default',
        'controller'    => 'list',
        'action'        => 'detail',
    ), array(
        'uid'           => '\d+',
        'title'         => '(.*)?',
    )));

This works.

Then I tried to change the route setup to using a .ini file where the routes are defined. The .ini file looks like this:

[routes]
pageDetails.route = "page-details/:uid/:title"
pageDetails.default.module = "default"
pageDetails.default.controller = "list"
pageDetails.default.action = "detail"
pageDetails.reqs.uid = "\d+"
pageDetails.reqs.title = "(.*)?"

And I add the routes in Bootstrap.php via:

    $config = Zend_Registry::get('config');

    $router = Zend_Controller_Front::getInstance()->getRouter();
    $router->addConfig(new Zend_Config_Ini($config['routes']['configPathname'], 'routes'));

Although the .ini version and the route defined in PHP code should do exactly the same, the .ini version does not work. There is no error message in the frontend, the links look allright but on clicking a link with this route I just get redirected to the start page.

What is missing?

  • 写回答

2条回答 默认 最新

  • doutang7707 2010-09-12 20:35
    关注

    You cannot use {}|&~![()^" characters in the key and you have to double-quote the string for the value if you use these characters.

    So double quote:

    pageDetails.reqs.title = ""(.*)?""
    

    For more on this see: http://php.net/manual/en/function.parse-ini-file.php

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable