PHP Class Bramus\Router\Router

Afficher le fichier Open project: bramus/router

Protected Properties

Свойство Type Description
$notFoundCallback The function to be executed when no route has been matched

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
getBasePath ( ) : string Return server base Path, and define it if isn't defined.
getCurrentUri ( ) : string Define the current relative URI

Private Methods

Méthode Description
handle ( array $routes, boolean $quitAfterRun = false ) : integer Handle a a set of routes: if a match is found, execute the relating handling function

Method Details

all() public méthode

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() public méthode

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() public méthode

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() public méthode

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() protected méthode

Return server base Path, and define it if isn't defined.
protected getBasePath ( ) : string
Résultat string

getCurrentUri() protected méthode

Define the current relative URI
protected getCurrentUri ( ) : string
Résultat string

getRequestHeaders() public méthode

Get all request headers
public getRequestHeaders ( ) : array
Résultat array The request headers

getRequestMethod() public méthode

Get the request method used, taking overrides into account
public getRequestMethod ( ) : string
Résultat string The Request method to handle

match() public méthode

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() public méthode

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() public méthode

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() public méthode

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() public méthode

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() public méthode

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() public méthode

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)
Résultat boolean

set404() public méthode

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

Property Details

$notFoundCallback protected_oe property

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