how to get dynamic URL like mydomain.com/username using zend framework

前端 未结 6 1632
孤街浪徒
孤街浪徒 2020-12-15 15:02

I am developing an application using zend framework. In the application I have to provide a URL for each user like mydomain.com/[username] then public will be able to view

6条回答
  •  孤城傲影
    2020-12-15 15:37

    Chellini's answer might work, but if you have 1000 users you are going to add 1000 rules to the router. That and the database access might add to your application's response time.

    An alternative is to add a generic route which by default maps to the user action (this is defined first as routes are matched in reverse order). Then add the routes to the controllers you actually have - you are likely to have far fewer controllers than users.

    If your application is modular, that reduces the number of rules you have to write even further as you just need to add one rule for a module.

提交回复
热议问题