PHP Mini Documentation

Router
in package
implements RouterInterface

Application Router

PHP Mini Framework

Tags
copyright

busarm.com

license

https://github.com/Busarm/php-mini/blob/master/LICENSE (MIT License)

Interfaces, Classes, Traits and Enums

RouterInterface
PHP Mini Framework

Table of Contents

ESCAPE_LIST  = ["/" => "\\/", "." => "\\."]
MATCHER_REGX  = ["/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ALPHA . "\\)/" => "([a-zA-Z]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ALPHA_NUM . "\\)/" => "([a-zA-Z-_]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ALPHA_NUM_DASH . "\\)/" => "([a-zA-Z0-9-_]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::NUM . "\\)/" => "([0-9]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ANY . "\\)/" => "(.+)"]
PARAM_NAME_REGX  = ["/\\{\\w*\\}/" => "([a-zA-Z0-9-_]+)"]
Use to match route path to an exact variable name. e.g $uid = /user/{uid}
PATH_EXCLUDE_LIST  = ["\$", "<", ">", "[", "]", "{", "}", "^", "\\", "|", "%"]
$routes  : array<string|int, RouteInterface>
addRoute()  : RouterInterface
addRoutes()  : RouterInterface
createRoute()  : RouteInterface
getRoutes()  : array<string|int, RouteInterface>
isMatch()  : bool|array<string|int, mixed>
Check if path matches
process()  : array<string|int, MiddlewareInterface>
Process routing
createMatchParamsRoute()  : string
Create route to be used for params matching

Constants

ESCAPE_LIST

public mixed ESCAPE_LIST = ["/" => "\\/", "." => "\\."]
Tags

MATCHER_REGX

public mixed MATCHER_REGX = ["/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ALPHA . "\\)/" => "([a-zA-Z]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ALPHA_NUM . "\\)/" => "([a-zA-Z-_]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ALPHA_NUM_DASH . "\\)/" => "([a-zA-Z0-9-_]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::NUM . "\\)/" => "([0-9]+)", "/\\(" . \Busarm\PhpMini\Enums\RouteMatcher::ANY . "\\)/" => "(.+)"]
Tags

PARAM_NAME_REGX

Use to match route path to an exact variable name. e.g $uid = /user/{uid}

public mixed PARAM_NAME_REGX = ["/\\{\\w*\\}/" => "([a-zA-Z0-9-_]+)"]
Tags

PATH_EXCLUDE_LIST

public mixed PATH_EXCLUDE_LIST = ["\$", "<", ">", "[", "]", "{", "}", "^", "\\", "|", "%"]
Tags

Properties

Methods

createRoute()

public createRoute(string $method, string $path) : RouteInterface
Parameters
$method : string

@see \Busarm\PhpMini\Enums\HttpMethod

$path : string
Tags
Return values
RouteInterface

isMatch()

Check if path matches

public isMatch(string $path, string $route[, bool $startsWith = true ][, mixed $endsWith = true ]) : bool|array<string|int, mixed>
Parameters
$path : string

Request path

$route : string

Route to compare to

$startsWith : bool = true

path ends with route

$endsWith : mixed = true
Tags
Return values
bool|array<string|int, mixed>

createMatchParamsRoute()

Create route to be used for params matching

protected createMatchParamsRoute(string $route[, mixed &$paramMatches = [] ]) : string
Parameters
$route : string
$paramMatches : mixed = []
Tags
Return values
string

New route for regexp matching


        

Search results