Documentation

Router
in package
implements RouterInterface, RequestMatcherInterface

The Router class is an example of the integration of all pieces of the routing system for easier use.

Tags
author

Fabien Potencier fabien@symfony.com

Interfaces, Classes and Traits

RouterInterface
RouterInterface is the interface that all Router classes must implement.
RequestMatcherInterface
RequestMatcherInterface is the interface that all request matcher classes must implement.

Table of Contents

$collection  : RouteCollection|null
$context  : RequestContext
$generator  : UrlGeneratorInterface|null
$loader  : LoaderInterface
$logger  : LoggerInterface|null
$matcher  : UrlMatcherInterface|null
$options  : array<string|int, mixed>
$resource  : mixed
$configCacheFactory  : ConfigCacheFactoryInterface|null
$expressionLanguageProviders  : array<string|int, ExpressionFunctionProviderInterface>
__construct()  : mixed
addExpressionLanguageProvider()  : mixed
generate()  : mixed
{@inheritdoc}
getContext()  : mixed
{@inheritdoc}
getGenerator()  : UrlGeneratorInterface
Gets the UrlGenerator instance associated with this Router.
getMatcher()  : UrlMatcherInterface|RequestMatcherInterface
Gets the UrlMatcher or RequestMatcher instance associated with this Router.
getOption()  : mixed
Gets an option value.
getRouteCollection()  : RouteCollection
Gets the RouteCollection instance associated with this Router.
match()  : mixed
{@inheritdoc}
matchRequest()  : array<string|int, mixed>
Tries to match a request with a set of routes.
setConfigCacheFactory()  : mixed
Sets the ConfigCache factory to use.
setContext()  : mixed
{@inheritdoc}
setOption()  : mixed
Sets an option.
setOptions()  : mixed
Sets options.
getGeneratorDumperInstance()  : GeneratorDumperInterface
getMatcherDumperInstance()  : MatcherDumperInterface
getConfigCacheFactory()  : ConfigCacheFactoryInterface
Provides the ConfigCache factory implementation, falling back to a default implementation if necessary.

Properties

$loader

protected LoaderInterface $loader

$options

protected array<string|int, mixed> $options = []

$resource

protected mixed $resource

$configCacheFactory

private ConfigCacheFactoryInterface|null $configCacheFactory

$expressionLanguageProviders

private array<string|int, ExpressionFunctionProviderInterface> $expressionLanguageProviders = []

Methods

__construct()

public __construct(LoaderInterface $loader, mixed $resource[, array<string|int, mixed> $options = [] ][, RequestContext $context = null ][, LoggerInterface $logger = null ]) : mixed
Parameters
$loader : LoaderInterface

A LoaderInterface instance

$resource : mixed

The main resource to load

$options : array<string|int, mixed> = []

An array of options

$context : RequestContext = null

The context

$logger : LoggerInterface = null

A logger instance

Return values
mixed

addExpressionLanguageProvider()

public addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider) : mixed
Parameters
$provider : ExpressionFunctionProviderInterface
Return values
mixed

generate()

{@inheritdoc}

public generate(mixed $name[, mixed $parameters = [] ][, mixed $referenceType = self::ABSOLUTE_PATH ]) : mixed
Parameters
$name : mixed
$parameters : mixed = []
$referenceType : mixed = self::ABSOLUTE_PATH
Return values
mixed

getContext()

{@inheritdoc}

public getContext() : mixed
Return values
mixed

getOption()

Gets an option value.

public getOption(string $key) : mixed
Parameters
$key : string

The key

Tags
throws
InvalidArgumentException
Return values
mixed

The value

getRouteCollection()

Gets the RouteCollection instance associated with this Router.

public getRouteCollection() : RouteCollection
Return values
RouteCollection

A RouteCollection instance

match()

{@inheritdoc}

public match(mixed $pathinfo) : mixed
Parameters
$pathinfo : mixed
Return values
mixed

matchRequest()

Tries to match a request with a set of routes.

public matchRequest(Request $request) : array<string|int, mixed>
Parameters
$request : Request
Return values
array<string|int, mixed>

An array of parameters

setConfigCacheFactory()

Sets the ConfigCache factory to use.

public setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory) : mixed
Parameters
$configCacheFactory : ConfigCacheFactoryInterface
Return values
mixed

setOption()

Sets an option.

public setOption(string $key, mixed $value) : mixed
Parameters
$key : string

The key

$value : mixed

The value

Tags
throws
InvalidArgumentException
Return values
mixed

setOptions()

Sets options.

public setOptions(array<string|int, mixed> $options) : mixed

Available options:

  • cache_dir: The cache directory (or null to disable caching)
  • debug: Whether to enable debugging or not (false by default)
  • generator_class: The name of a UrlGeneratorInterface implementation
  • generator_base_class: The base class for the dumped generator class
  • generator_cache_class: The class name for the dumped generator class
  • generator_dumper_class: The name of a GeneratorDumperInterface implementation
  • matcher_class: The name of a UrlMatcherInterface implementation
  • matcher_base_class: The base class for the dumped matcher class
  • matcher_dumper_class: The class name for the dumped matcher class
  • matcher_cache_class: The name of a MatcherDumperInterface implementation
  • resource_type: Type hint for the main resource (optional)
  • strict_requirements: Configure strict requirement checking for generators implementing ConfigurableRequirementsInterface (default is true)
Parameters
$options : array<string|int, mixed>

An array of options

Tags
throws
InvalidArgumentException

When unsupported option is provided

Return values
mixed

getConfigCacheFactory()

Provides the ConfigCache factory implementation, falling back to a default implementation if necessary.

private getConfigCacheFactory() : ConfigCacheFactoryInterface
Return values
ConfigCacheFactoryInterface

Search results