Documentation

Router
in package

Table of Contents

Constants

TRIM_REGEXP  = "/^\\/+|\\/\$/m"

Properties

$callback  : mixed
$env  : array<string|int, mixed>
$isMatched  : bool
$notFoundHandler  : mixed
$PREFIX  : string
$request  : Request
$requestMethod  : Methods
$requestURISubPaths  : array<string|int, mixed>
$response  : Response

Methods

__construct()  : mixed
delete()  : mixed
handle DELETE request
get()  : mixed
handle GET request
notFound()  : mixed
handle not found page
post()  : mixed
handle POST request
put()  : mixed
handle PUT request
start()  : mixed
start listening handled routes
getParameterValuesFromURI()  : object
match pattern parameter sub paths to request sub paths
registerRoute()  : void
trimURI()  : string
trim URI from /

Constants

TRIM_REGEXP

private mixed TRIM_REGEXP = "/^\\/+|\\/\$/m"

Properties

$callback

private mixed $callback

$env

private array<string|int, mixed> $env

$isMatched

private bool $isMatched = false

$notFoundHandler

private mixed $notFoundHandler

$requestURISubPaths

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

Methods

__construct()

public __construct() : mixed

delete()

handle DELETE request

public delete(string $path, callable $handler) : mixed
Parameters
$path : string

path on which request must be handled

$handler : callable

function which will be executed

get()

handle GET request

public get(string $path, callable $handler) : mixed
Parameters
$path : string

path on which request must be handled

$handler : callable

function which will be executed

notFound()

handle not found page

public notFound(callable $handler) : mixed
Parameters
$handler : callable

post()

handle POST request

public post(string $path, callable $handler) : mixed
Parameters
$path : string

path on which request must be handled

$handler : callable

function which will be executed

put()

handle PUT request

public put(string $path, callable $handler) : mixed
Parameters
$path : string

path on which request must be handled

$handler : callable

function which will be executed

start()

start listening handled routes

public start() : mixed

getParameterValuesFromURI()

match pattern parameter sub paths to request sub paths

private getParameterValuesFromURI(array<string|int, string> $patternURISubPaths, array<string|int, string> $requestURISubPaths) : object
Parameters
$patternURISubPaths : array<string|int, string>

["users", ":id", "update"]

$requestURISubPaths : array<string|int, string>

["users", "a2e-a65-2ab", "update"]

Return values
object

{id: "a2e-a65-2ab"}

registerRoute()

private registerRoute(Methods $method, string $path, callable $handler) : void
Parameters
$method : Methods

HTTP request method

$path : string

path on which request must be handled

$handler : callable

function which will be executed

trimURI()

trim URI from /

private trimURI(string $uri) : string
Parameters
$uri : string
Return values
string

        
On this page

Search results