Updated: Best practices for managing static content in Zend Framework?

后端 未结 2 1693
执笔经年
执笔经年 2021-02-09 12:29

I have some questions concerning the Zend Framework. I am attempting to route all static pages through the default controller using the now default displayAction()

相关标签:
2条回答
  • 2021-02-09 13:17

    I think your on the right track however here are some other ideas.

    Break up your routing per sections in your INI: ie a blog router, a static page router a forum router etc.. (I think you are already doing this)

    Use the various router classes to handle routing per section rather than sending it to a controller.

    Static: http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.static

    All: http://framework.zend.com/manual/en/zend.controller.router.html

    Some links that may help:

    • codeutopia.net/blog/2007/11/16/routing-and-complex-urls-in-zend-framework/
    • www.vayanis.com/2009/03/20/intro-to-zend-framework-routing/
    0 讨论(0)
  • 2021-02-09 13:24

    Your approach seems reasonable to me. However, perhaps you should take advantage of the __call method instead, which would allow you to more easily route your actions...

    Setup your route like this:

    resources.router.routes.static-pages.route = /:action
    resources.router.routes.static-pages.defaults.module = default
    resources.router.routes.static-pages.defaults.controller = index
    

    And your controller like so:

    public function someAction() {
        //going to URL /some will now go into this method
    }
    
    public function __call($name, $args) {
        //all URLs which don't have a matching action method will go to this one
    }
    
    0 讨论(0)
提交回复
热议问题