Overview

Namespaces

  • api
  • config
  • database
  • None
  • PHP
  • Slim
    • Exception
    • Http
    • Middleware
  • utiliy

Classes

  • Environment
  • Log
  • LogWriter
  • Middleware
  • Route
  • Router
  • Slim
  • View
  • Overview
  • Namespace
  • Class
  • Tree

Class Router

Router

This class organizes, iterates, and dispatches \Slim\Route objects.

Namespace: Slim
Package: Slim
Author: Josh Lockhart
Since: 1.0.0
Located at thirdparty/Slim/Router.php
Methods summary
public
# __construct( )

Constructor

Constructor

public Slim\Route|null
# getCurrentRoute( )

Get Current Route object or the first matched one if matching has been performed

Get Current Route object or the first matched one if matching has been performed

Returns

Slim\Route|null
public array[\Slim\Route]
# getMatchedRoutes( string $httpMethod, string $resourceUri, boolean $reload = false )

Return route objects that match the given HTTP method and URI

Return route objects that match the given HTTP method and URI

Parameters

$httpMethod
string
$httpMethod The HTTP method to match against
$resourceUri
string
$resourceUri The resource URI to match against
$reload
boolean
$reload Should matching routes be re-parsed?

Returns

array[\Slim\Route]
public Slim\Route
# map( string $pattern, mixed $callable )

Map a route object to a callback function

Map a route object to a callback function

Parameters

$pattern
string
$pattern The URL pattern (ie. "/books/:id")
$callable
mixed
$callable Anything that returns TRUE for is_callable()

Returns

Slim\Route
public string
# urlFor( string $name, array $params = array() )

Get URL for named route

Get URL for named route

Parameters

$name
string
$name The name of the route
$params
array
Associative array of URL parameter names and replacement values

Returns

string
The URL for the given route populated with provided replacement values

Throws

RuntimeException
If named route not found
public boolean
# dispatch( Slim\Route $route )

Dispatch route

Dispatch route

This method invokes the route object's callable. If middleware is registered for the route, each callable middleware is invoked in the order specified.

Parameters

$route
Slim\Route
$route The route object

Returns

boolean
Was route callable invoked successfully?
public
# addNamedRoute( string $name, Slim\Route $route )

Add named route

Add named route

Parameters

$name
string
$name The route name
$route
Slim\Route
$route The route object

Throws

RuntimeException
If a named route already exists with the same name
public boolean
# hasNamedRoute( string $name )

Has named route

Has named route

Parameters

$name
string
$name The route name

Returns

boolean
public Slim\Route|null
# getNamedRoute( string $name )

Get named route

Get named route

Parameters

$name
string
$name

Returns

Slim\Route|null
public ArrayIterator
# getNamedRoutes( )

Get named routes

Get named routes

Returns

ArrayIterator
Properties summary
protected Slim\Route $currentRoute
#

The current route (most recently dispatched)

The current route (most recently dispatched)

protected array $routes
#

Lookup hash of all route objects

Lookup hash of all route objects

protected array $namedRoutes
#

Lookup hash of named route objects, keyed by route name (lazy-loaded)

Lookup hash of named route objects, keyed by route name (lazy-loaded)

protected array $matchedRoutes
#

Array of route objects that match the request URI (lazy-loaded)

Array of route objects that match the request URI (lazy-loaded)

GeoApi API documentation generated by ApiGen 2.8.0