Documentation

Route
in package
Uses HttpMethod

Table of Contents

NAME_REPLACEMENTS  = ["-" => "_", "." => "§2E", "ä" => "ae", "ö" => "oe", "ü" => "ue"]
$storedPrefixedGroups  : array<string|int, mixed>
$collector  : RouteCollector|null
The active FastRoute collector.
$groupStateStack  : array<string|int, mixed>
Stack to manage middleware inheritance of nested groups.
$prefixStack  : array<string|int, mixed>
Stack to manage group prefixes.
any()  : PendingRoute
define()  : PendingRoute
delete()  : PendingRoute
get()  : PendingRoute
group()  : PendingGroup
init()  : void
Initializes the static Router.
options()  : PendingRoute
patch()  : PendingRoute
performGroup()  : void
Stores the group's middlewares under its full prefix for fallback matching, then runs $callback with the group state pushed and pops it afterwards.
performRoute()  : void
performStoredGroupsMatchingPrefix()  : void
Runs the middlewares of all groups matching the URL (exits if one returns non-true), then $callback, then the after-middlewares.
post()  : PendingRoute
put()  : PendingRoute
buildEndpoint()  : string
callControllerAction()  : mixed
getCurrentRouter()  : RouteCollector
Gets the current route collector.
getInheritedAfterMiddlewares()  : array<string|int, mixed>
getInheritedMiddlewares()  : array<string|int, mixed>
performCallableAction()  : void
Keeps callback compatibility with route closures using 0..3 parameters, injected by type: array gets the route args, Request/Response the current instances, anything else its default value or null.
resolveMethod()  : string|array<string|int, mixed>

Constants

NAME_REPLACEMENTS

public mixed NAME_REPLACEMENTS = ["-" => "_", "." => "§2E", "ä" => "ae", "ö" => "oe", "ü" => "ue"]

Properties

$storedPrefixedGroups

public static array<string|int, mixed> $storedPrefixedGroups = []

$collector

The active FastRoute collector.

private static RouteCollector|null $collector = null

$groupStateStack

Stack to manage middleware inheritance of nested groups.

private static array<string|int, mixed> $groupStateStack = []

array<int, array{middleware: array, afterMiddleware: array}>

$prefixStack

Stack to manage group prefixes.

private static array<string|int, mixed> $prefixStack = []

Methods

any()

public static any(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

define()

public static define(string $method, string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$method : string
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

delete()

public static delete(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

get()

public static get(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

group()

public static group([string $prefix = "" ][, callable|null $callback = null ]) : PendingGroup
Parameters
$prefix : string = ""
$callback : callable|null = null
Return values
PendingGroup —

init()

Initializes the static Router.

public static init(ZubZet $booter, RouteCollector $collector) : void

This must be called once before loading route files. Also resets the prefix stack, group state and stored groups, discarding earlier registrations.

Parameters
$booter : ZubZet

Unused.

$collector : RouteCollector

Collector all following routes are registered on.

Return values
void —

options()

public static options(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

patch()

public static patch(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

performGroup()

Stores the group's middlewares under its full prefix for fallback matching, then runs $callback with the group state pushed and pops it afterwards.

public static performGroup(string $prefix, callable $callback, array<string|int, mixed> $middlewares, array<string|int, mixed> $afterMiddleware) : void
Parameters
$prefix : string

Path segment appended to the enclosing group prefixes

$callback : callable

Declares the routes inside the group

$middlewares : array<string|int, mixed>

Run before the action of every route in the group

$afterMiddleware : array<string|int, mixed>

Run after the action of every route in the group

Return values
void —

performRoute()

public static performRoute(string $method, string $endpoint, PendingAction $action, array<string|int, mixed> $middlewares, array<string|int, mixed> $afterMiddleware) : void
Parameters
$method : string
$endpoint : string
$action : PendingAction
$middlewares : array<string|int, mixed>
$afterMiddleware : array<string|int, mixed>
Return values
void —

performStoredGroupsMatchingPrefix()

Runs the middlewares of all groups matching the URL (exits if one returns non-true), then $callback, then the after-middlewares.

public static performStoredGroupsMatchingPrefix(array<string|int, mixed> $urlParts, Closure|callable $callback) : void
Parameters
$urlParts : array<string|int, mixed>

URL segments of the current request

$callback : Closure|callable

Runs after the middlewares passed, e.g. the controller action

Return values
void —

post()

public static post(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

put()

public static put(string $endpoint, array<string|int, mixed>|callable $action[, array<string|int, mixed> $arguments = [] ]) : PendingRoute
Parameters
$endpoint : string
$action : array<string|int, mixed>|callable
$arguments : array<string|int, mixed> = []
Return values
PendingRoute —

buildEndpoint()

private static buildEndpoint(string $endpoint) : string
Parameters
$endpoint : string
Return values
string —

callControllerAction()

private static callControllerAction(string $class, string $method[, array<string|int, mixed> $args = [] ][, array<string|int, mixed> $arguments = [] ]) : mixed
Parameters
$class : string
$method : string
$args : array<string|int, mixed> = []
$arguments : array<string|int, mixed> = []
Return values
mixed —

getCurrentRouter()

Gets the current route collector.

private static getCurrentRouter() : RouteCollector
Return values
RouteCollector —

getInheritedAfterMiddlewares()

private static getInheritedAfterMiddlewares() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getInheritedMiddlewares()

private static getInheritedMiddlewares() : array<string|int, mixed>
Return values
array<string|int, mixed> —

performCallableAction()

Keeps callback compatibility with route closures using 0..3 parameters, injected by type: array gets the route args, Request/Response the current instances, anything else its default value or null.

private static performCallableAction(callable $action, array<string|int, mixed> $args) : void
Parameters
$action : callable
$args : array<string|int, mixed>
Return values
void —

resolveMethod()

private static resolveMethod(string $method) : string|array<string|int, mixed>
Parameters
$method : string
Return values
string|array<string|int, mixed> —

Search results