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 Route

Route

Namespace: Slim
Package: Slim
Author: Josh Lockhart, Thomas Bley
Since: 1.0.0
Located at thirdparty/Slim/Route.php
Methods summary
public
# __construct( string $pattern, mixed $callable )

Constructor

Constructor

Parameters

$pattern
string
$pattern The URL pattern (e.g. "/books/:id")
$callable
mixed
$callable Anything that returns TRUE for is_callable()
public static
# setDefaultConditions( array $defaultConditions )

Set default route conditions for all instances

Set default route conditions for all instances

Parameters

$defaultConditions
array
$defaultConditions
public static array
# getDefaultConditions( )

Get default route conditions for all instances

Get default route conditions for all instances

Returns

array
public string
# getPattern( )

Get route pattern

Get route pattern

Returns

string
public
# setPattern( string $pattern )

Set route pattern

Set route pattern

Parameters

$pattern
string
$pattern
public mixed
# getCallable( )

Get route callable

Get route callable

Returns

mixed
public
# setCallable( mixed $callable )

Set route callable

Set route callable

Parameters

$callable
mixed
$callable

Throws

InvalidArgumentException
If argument is not callable
public array
# getConditions( )

Get route conditions

Get route conditions

Returns

array
public
# setConditions( array $conditions )

Set route conditions

Set route conditions

Parameters

$conditions
array
$conditions
public string|null
# getName( )

Get route name

Get route name

Returns

string|null
public
# setName( string $name )

Set route name

Set route name

Parameters

$name
string
$name
public array
# getParams( )

Get route parameters

Get route parameters

Returns

array
public
# setParams( array $params )

Set route parameters

Set route parameters

Parameters

$params
array
$params
public string
# getParam( string $index )

Get route parameter value

Get route parameter value

Parameters

$index
string
$index Name of URL parameter

Returns

string

Throws

InvalidArgumentException
If route parameter does not exist at index
public
# setParam( string $index, mixed $value )

Set route parameter value

Set route parameter value

Parameters

$index
string
$index Name of URL parameter
$value
mixed
$value The new parameter value

Throws

InvalidArgumentException
If route parameter does not exist at index
public
# setHttpMethods( )

Add supported HTTP method(s)

Add supported HTTP method(s)

public array
# getHttpMethods( )

Get supported HTTP methods

Get supported HTTP methods

Returns

array
public
# appendHttpMethods( )

Append supported HTTP methods

Append supported HTTP methods

public Slim\Route
# via( )

Append supported HTTP methods (alias for Route::appendHttpMethods)

Append supported HTTP methods (alias for Route::appendHttpMethods)

Returns

Slim\Route
public boolean
# supportsHttpMethod( mixed $method )

Detect support for an HTTP method

Detect support for an HTTP method

Returns

boolean
public array[Callable]
# getMiddleware( )

Get middleware

Get middleware

Returns

array[Callable]
public Slim\Route
# setMiddleware( Callable|array[Callable] $middleware )

Set middleware

Set middleware

This method allows middleware to be assigned to a specific Route. If the method argument is_callable (including callable arrays!), we directly append the argument to $this->middleware. Else, we assume the argument is an array of callables and merge the array with $this->middleware. Each middleware is checked for is_callable() and an InvalidArgumentException is thrown immediately if it isn't.

Parameters

$middleware
Callable|array[Callable]

Returns

Slim\Route

Throws

InvalidArgumentException
If argument is not callable or not an array of callables.
public boolean
# matches( string $resourceUri )

Matches URI?

Matches URI?

Parse this route's pattern, and then compare it to an HTTP resource URI This method was modeled after the techniques demonstrated by Dan Sosedoff at:

http://blog.sosedoff.com/2009/09/20/rails-like-php-url-router/

Parameters

$resourceUri
string
$resourceUri A Request URI

Returns

boolean
protected string
# matchesCallback( array $m )

Convert a URL parameter (e.g. ":id", ":id+") into a regular expression

Convert a URL parameter (e.g. ":id", ":id+") into a regular expression

Parameters

$m
array
URL parameters

Returns

string
Regular expression for URL parameter
public Slim\Route
# name( string $name )

Set route name

Set route name

Parameters

$name
string
$name The name of the route

Returns

Slim\Route
public Slim\Route
# conditions( array $conditions )

Merge route conditions

Merge route conditions

Parameters

$conditions
array
$conditions Key-value array of URL parameter conditions

Returns

Slim\Route
Properties summary
protected string $pattern
#

The route pattern (e.g. "/books/:id")

The route pattern (e.g. "/books/:id")

protected mixed $callable
#

The route callable

The route callable

protected array $conditions array()
#

Conditions for this route's URL parameters

Conditions for this route's URL parameters

protected static array $defaultConditions array()
#

Default conditions applied to all route instances

Default conditions applied to all route instances

protected string $name
#

The name of this route (optional)

The name of this route (optional)

protected array $params array()
#

Key-value array of URL parameters

Key-value array of URL parameters

protected array $paramNames array()
#

value array of URL parameter names

value array of URL parameter names

protected array $paramNamesPath array()
#

key array of URL parameter names with + at the end

key array of URL parameter names with + at the end

protected array $methods array()
#

HTTP methods supported by this Route

HTTP methods supported by this Route

protected array[Callable] $middleware array()
#

Middleware to be run before only this route instance

Middleware to be run before only this route instance

GeoApi API documentation generated by ApiGen 2.8.0