PHP Application URL Routing

后端 未结 8 1944
梦毁少年i
梦毁少年i 2020-11-29 00:15

So I\'m writing a framework on which I want to base a few apps that I\'m working on (the framework is there so I have an environment to work with, and a system that will let

8条回答
  •  不知归路
    2020-11-29 00:35

    Use a list of Regexs to match which object I should be using

    For example

    ^/users/[\w-]+/bookmarks/(.+)/$
    ^/users/[\w-]+/bookmarks/$
    ^/users/[\w-]+/$
    

    Pros: Nice and simple, lets me define routes directly Cons: Would have to be ordered, not making it easy to add new things in (very error prone)

    This is, afaik, how Django does it

提交回复
热议问题