PHP Interface Autarky\Routing\RouterInterface

Show file Open project: autarky/framework Interface Usage Examples

Public Methods

Method Description
addRoute ( string | array $method, string $path, string $handler, string $name = null ) Add a route to the router.
dispatch ( Request $request ) : Response Dispatch a request in the router.
getCurrentRoute ( ) : Route Get the route matched to the current request.
getRoute ( string $name ) : Route Given a route name, get the route object.
group ( array $flags, Closure $callback ) : void Define a route group.
mount ( array $routes, string $path = '/' ) : void Mount an array config onto the routes.

Method Details

addRoute() public method

Add a route to the router.
public addRoute ( string | array $method, string $path, string $handler, string $name = null )
$method string | array HTTP methods the route should respond to
$path string Relative URL the route should respond to. Parameters wrapped in }
$handler string string of "class:method" or "global_function"
$name string Route name (optional)

dispatch() public method

Dispatch a request in the router.
public dispatch ( Request $request ) : Response
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\Response

getCurrentRoute() public method

Get the route matched to the current request.
public getCurrentRoute ( ) : Route
return Route

getRoute() public method

Given a route name, get the route object.
public getRoute ( string $name ) : Route
$name string
return Route

group() public method

Define a route group.
public group ( array $flags, Closure $callback ) : void
$flags array Valid keys are 'before', 'after', 'prefix'
$callback Closure First argument is the router ($this)
return void

mount() public method

Mount an array config onto the routes.
public mount ( array $routes, string $path = '/' ) : void
$routes array
$path string
return void