PHP Класс Bramus\Router\Router

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$notFoundCallback The function to be executed when no route has been matched

Открытые методы

Метод Описание
all ( string $pattern, object | callable $fn ) Shorthand for a route accessed using any method
before ( string $methods, string $pattern, object | callable $fn ) Store a before middleware route and a handling function to be executed when accessed using one of the specified methods
delete ( string $pattern, object | callable $fn ) Shorthand for a route accessed using DELETE
get ( string $pattern, object | callable $fn ) Shorthand for a route accessed using GET
getRequestHeaders ( ) : array Get all request headers
getRequestMethod ( ) : string Get the request method used, taking overrides into account
match ( string $methods, string $pattern, object | callable $fn ) Store a route and a handling function to be executed when accessed using one of the specified methods
mount ( string $baseRoute, callable $fn ) Mounts a collection of callbacks onto a base route
options ( string $pattern, object | callable $fn ) Shorthand for a route accessed using OPTIONS
patch ( string $pattern, object | callable $fn ) Shorthand for a route accessed using PATCH
post ( string $pattern, object | callable $fn ) Shorthand for a route accessed using POST
put ( string $pattern, object | callable $fn ) Shorthand for a route accessed using PUT
run ( object | callable $callback = null ) : boolean Execute the router: Loop all defined before middleware's and routes, and execute the handling function if a match was found
set404 ( object | callable $fn ) Set the 404 handling function

Защищенные методы

Метод Описание
getBasePath ( ) : string Return server base Path, and define it if isn't defined.
getCurrentUri ( ) : string Define the current relative URI

Приватные методы

Метод Описание
handle ( array $routes, boolean $quitAfterRun = false ) : integer Handle a a set of routes: if a match is found, execute the relating handling function

Описание методов

all() публичный Метод

Shorthand for a route accessed using any method
public all ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

before() публичный Метод

Store a before middleware route and a handling function to be executed when accessed using one of the specified methods
public before ( string $methods, string $pattern, object | callable $fn )
$methods string Allowed methods, | delimited
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

delete() публичный Метод

Shorthand for a route accessed using DELETE
public delete ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

get() публичный Метод

Shorthand for a route accessed using GET
public get ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

getBasePath() защищенный Метод

Return server base Path, and define it if isn't defined.
protected getBasePath ( ) : string
Результат string

getCurrentUri() защищенный Метод

Define the current relative URI
protected getCurrentUri ( ) : string
Результат string

getRequestHeaders() публичный Метод

Get all request headers
public getRequestHeaders ( ) : array
Результат array The request headers

getRequestMethod() публичный Метод

Get the request method used, taking overrides into account
public getRequestMethod ( ) : string
Результат string The Request method to handle

match() публичный Метод

Store a route and a handling function to be executed when accessed using one of the specified methods
public match ( string $methods, string $pattern, object | callable $fn )
$methods string Allowed methods, | delimited
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

mount() публичный Метод

Mounts a collection of callbacks onto a base route
public mount ( string $baseRoute, callable $fn )
$baseRoute string The route sub pattern to mount the callbacks on
$fn callable The callback method

options() публичный Метод

Shorthand for a route accessed using OPTIONS
public options ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

patch() публичный Метод

Shorthand for a route accessed using PATCH
public patch ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

post() публичный Метод

Shorthand for a route accessed using POST
public post ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

put() публичный Метод

Shorthand for a route accessed using PUT
public put ( string $pattern, object | callable $fn )
$pattern string A route pattern such as /about/system
$fn object | callable The handling function to be executed

run() публичный Метод

Execute the router: Loop all defined before middleware's and routes, and execute the handling function if a match was found
public run ( object | callable $callback = null ) : boolean
$callback object | callable Function to be executed after a matching route was handled (= after router middleware)
Результат boolean

set404() публичный Метод

Set the 404 handling function
public set404 ( object | callable $fn )
$fn object | callable The function to be executed

Описание свойств

$notFoundCallback защищенное свойство

The function to be executed when no route has been matched
protected $notFoundCallback