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

后端 未结 2 1694
执笔经年
执笔经年 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: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
    }
    

提交回复
热议问题