PHP Application URL Routing

后端 未结 8 1880
梦毁少年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:45

    Zend's MVC framework by default uses a structure like

    /router/controller/action/key1/value1/key2/value2
    

    where router is the router file (mapped via mod_rewrite, controller is from a controller action handler which is defined by a class that derives from Zend_Controller_Action and action references a method in the controller, named actionAction. The key/value pairs can go in any order and are available to the action method as an associative array.

    I've used something similar in the past in my own code, and so far it's worked fairly well.

    0 讨论(0)
  • 2020-11-29 00:48

    I think a lot of frameworks use a combination of Apache's mod_rewrite and a front controller. With mod_rewrite, you can turn a URL like this: /people/get/3 into this: index.php?controller=people&method=get&id=3. Index.php would implement your front controller which routes the page request based on the parameters given.

    0 讨论(0)
提交回复
热议问题