ScopedRouter
in package
implements
IRouter
Uses
RouterTrait
Table of Contents
Interfaces
Methods
- __construct() : mixed
- add() : void
- Adds a new route.
- delete() : void
- get() : void
- options() : void
- patch() : void
- post() : void
- put() : void
- register() : void
- resolve() : ResolvedRouteInfo
- Resolves a route
- scopeTo() : IRouter
- Creates a scoped version of this router.
- use() : void
- Apply middleware functions to a path.
Methods
__construct()
public
__construct(IRouter $router, string $prefix) : mixed
Parameters
- $router : IRouter
- $prefix : string
add()
Adds a new route.
public
add(string $method, string $path, callable $handler) : void
Parameters
- $method : string
-
Request method.
- $path : string
-
Request path.
- $handler : callable
-
Request handler.
delete()
public
delete(string $path, callable $handler) : void
Parameters
- $path : string
- $handler : callable
get()
public
get(string $path, callable $handler) : void
Parameters
- $path : string
- $handler : callable
options()
public
options(string $path, callable $handler) : void
Parameters
- $path : string
- $handler : callable
patch()
public
patch(string $path, callable $handler) : void
Parameters
- $path : string
- $handler : callable
post()
public
post(string $path, callable $handler) : void
Parameters
- $path : string
- $handler : callable
put()
public
put(string $path, callable $handler) : void
Parameters
- $path : string
- $handler : callable
register()
public
register(IRouteHandler $handler) : void
Parameters
- $handler : IRouteHandler
resolve()
Resolves a route
public
resolve(string $method, string $path) : ResolvedRouteInfo
Parameters
- $method : string
-
Request method.
- $path : string
-
Request path.
Return values
ResolvedRouteInfo —Response route.
scopeTo()
Creates a scoped version of this router.
public
scopeTo(string $prefix) : IRouter
Parameters
- $prefix : string
-
Prefix path to prepend to all registered routes.
Return values
IRouter —Scoped router.
use()
Apply middleware functions to a path.
public
use(string $path, callable $handler) : void
Parameters
- $path : string
-
Path to apply the middleware to.
- $handler : callable
-
Middleware function.