ZF 1.5x的一点变化

今天把Zend Framework升级到了1.5.1最新版,发现有些连接访问出错,查官方文档发现是因为Action里面的“驼峰命名”方式的改变导致。

原来的情况是这样:假如我们有个 aaaBbbController::cccDddAction这么一个东西,访问的url可以是 /aaabbb/cccddd/ 也可以是 /aaaBbb/cccDdd/
现在的情况是这样:要么把方法写成 aaabbbController::cccdddAction 统一的小写,要么url里面改成这样 /aaa.bbb/ccc.ddd/ 或者 /aaa-bbb/ccc-ddd/

我还没有来得及搞明白这样改进的好处是什么。

官方文档:
7.13.1. Migrating from 1.0.x to 1.5.0 or newer
CamelCasedNamingConventions

Category: PHP / Zend  Tags:
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
5 Responses
  1. 黔驴 says:

    官方提供了一个解决办法是:
    $frontController->setParam(‘useCaseSensitiveActions’, true);
    不过会产生一条E_USER_NOTICE级的错误信息,屏蔽掉就好.
    详情请查看
    Zend/Controller/Action.php中的dispatch方法

  2. Michael says:

    [Comment ID #26166 Will Be Quoted Here]

    文档提供了三种方法,您说的那种方法被列为最佳、折中之后的第三种解决办法,还是不建议采用。

  3. blankyao says:

    FleaPHP在这方面做得也不好,然后就在Qeephp中改进了下,文件名统一小写….

  4. niule says:

    实在不知道哪里给你留言了呵呵

    请教个问题

    我现在用zf做项目,关于静态页面,你是怎么处理的?
    我想要的是,能够直接访问静态页面,而不经过controller。

    不知道你项目里是怎么用的,谢啦!

  5. Michael says:

    [Comment ID #29824 Will Be Quoted Here]
    如果你要用纯粹的controller,可以配置服务器的rewrite规则,对于明确的.html等静态页面的url访问可以不进行rewrite到index.php,或者对于某些存放静态页面的特定目录不rewrite,这是唯一的办法。

    另外,如果使用zf不使用它的controller机制,那就可以只把他当作类似pear的模块来使用,这样就不用都走index.php了。

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image