Skip to content

AutoRouter

szeber edited this page Jun 13, 2012 · 3 revisions

This is the simplest router, it requires no configuration to operate. It splits the target by the path separator (/) and takes the first part as the controller name, the second part as the action name. Any remaining parts will be set as request parameters in the request object with the number of the part being the key. The original list of parts is zero indexed, so the third part, which becomes the first parameter is set as parameter 2.

If there is no action in the request it will be replaced by 'Index', if the controller part is missing it's also replaced by 'Index'.

Examples

Target: /

Controller: Index Action: Index Parameters: array()


Target: /faq

Controller: Faq Action: Index Parameters: array()


Target: /user/list

Controller: User Action: List Parameters: array()


Target: /user/details/photo

Controller: User Action: Details Parameters: array(2 => 'photo')

Clone this wiki locally