Skip to content

Array parameter routing (idea) #38

@emlynwest

Description

@emlynwest

The idea is to be able to have a "match many" parameter when defining routes. This would allow the ability to pass any number of segments as an array to an action.

Example:
Define a route to match controller/action/names/[]/foo/bar where the [] would be a place-holder marker that matches any number of segments until the one after it is matched (in this case foo).

This would then be passed to the action like so:

public function action_action($names, $foo, $bar){}

$names would then be an array populated with anything that is found between the names and foo segment, or an empty array if none where matched.

A route such as controller/action/names/tom/dick/harry/foo/bar would pass the parameters below to the action.

$names = array('tom', 'dick', 'harry');
$foo = 'foo';
$bar = 'bar';

This could then also work with multiple array segments: controller/action/names/[]/ages/[] to pass multiple arrays to the action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions