Overview

Namespaces

  • Evenement
  • None
  • PHP
  • Psr
    • Http
      • Message
  • Ratchet
    • Http
    • RFC6455
      • Handshake
      • Messaging
    • Server
    • Session
      • Serialize
      • Storage
        • Proxy
    • Wamp
    • WebSocket
  • React
    • EventLoop
      • Tick
      • Timer
    • Socket
    • Stream
  • Symfony
    • Component
      • HttpFoundation
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
      • Routing
        • Annotation
        • Exception
        • Generator
          • Dumper
        • Loader
          • DependencyInjection
        • Matcher
          • Dumper
        • Tests
          • Annotation
          • Fixtures
            • AnnotatedClasses
            • OtherAnnotatedClasses
          • Generator
            • Dumper
          • Loader
          • Matcher
            • Dumper

Classes

  • CompiledRoute
  • RequestContext
  • Route
  • RouteCollection
  • RouteCollectionBuilder
  • RouteCompiler
  • Router

Interfaces

  • RequestContextAwareInterface
  • RouteCompilerInterface
  • RouterInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class Router

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

Symfony\Component\Routing\Router implements Symfony\Component\Routing\RouterInterface, Symfony\Component\Routing\Matcher\RequestMatcherInterface
Namespace: Symfony\Component\Routing
Author: Fabien Potencier <fabien@symfony.com>
Located at Router.php
Methods summary
public
# __construct( Symfony\Component\Config\Loader\LoaderInterface $loader, mixed $resource, array $options = array(), Symfony\Component\Routing\RequestContext $context = null, Psr\Log\LoggerInterface $logger = null )

Constructor.

Constructor.

Parameters

$loader
Symfony\Component\Config\Loader\LoaderInterface
$loader A LoaderInterface instance
$resource
mixed
$resource The main resource to load
$options
array
$options An array of options
$context
Symfony\Component\Routing\RequestContext
$context The context
$logger
Psr\Log\LoggerInterface
$logger A logger instance
public
# setOptions( array $options )

Sets options.

Sets options.

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
$options An array of options

Throws

InvalidArgumentException
When unsupported option is provided
public
# setOption( string $key, mixed $value )

Sets an option.

Sets an option.

Parameters

$key
string
$key The key
$value
mixed
$value The value

Throws

InvalidArgumentException
public mixed
# getOption( string $key )

Gets an option value.

Gets an option value.

Parameters

$key
string
$key The key

Returns

mixed
The value

Throws

InvalidArgumentException
public Symfony\Component\Routing\RouteCollection
# getRouteCollection( )

Gets the RouteCollection instance associated with this Router.

Gets the RouteCollection instance associated with this Router.

Returns

Symfony\Component\Routing\RouteCollection
A RouteCollection instance

Implementation of

Symfony\Component\Routing\RouterInterface::getRouteCollection()
public
# setContext( Symfony\Component\Routing\RequestContext $context )

Sets the request context.

Sets the request context.

Parameters

$context
Symfony\Component\Routing\RequestContext
$context The context

Implementation of

Symfony\Component\Routing\RequestContextAwareInterface::setContext()
public Symfony\Component\Routing\RequestContext
# getContext( )

Gets the request context.

Gets the request context.

Returns

Symfony\Component\Routing\RequestContext
The context

Implementation of

Symfony\Component\Routing\RequestContextAwareInterface::getContext()
public
# setConfigCacheFactory( Symfony\Component\Config\ConfigCacheFactoryInterface $configCacheFactory )

Sets the ConfigCache factory to use.

Sets the ConfigCache factory to use.

Parameters

$configCacheFactory
Symfony\Component\Config\ConfigCacheFactoryInterface
$configCacheFactory The factory to use
public string
# generate( string $name, mixed $parameters = array(), integer $referenceType = Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_PATH )

Generates a URL or path for a specific route based on the given parameters.

Generates a URL or path for a specific route based on the given parameters.

Parameters

$name
string
$name The name of the route
$parameters
mixed
$parameters An array of parameters
$referenceType
integer
$referenceType The type of reference to be generated (one of the constants)

Returns

string
The generated URL

Throws

RouteNotFoundException
If the named route doesn't exist
MissingMandatoryParametersException
When some parameters are missing that are mandatory for the route
InvalidParameterException
When a parameter value for a placeholder is not correct because it does not match the requirement

Implementation of

Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate()
public array
# match( string $pathinfo )

Tries to match a URL path with a set of routes.

Tries to match a URL path with a set of routes.

Parameters

$pathinfo
string
$pathinfo The path info to be parsed (raw format, i.e. not urldecoded)

Returns

array
An array of parameters

Throws

ResourceNotFoundException
If the resource could not be found
MethodNotAllowedException
If the resource was found but the request method is not allowed

Implementation of

Symfony\Component\Routing\Matcher\UrlMatcherInterface::match()
public array
# matchRequest( Symfony\Component\HttpFoundation\Request $request )

Tries to match a request with a set of routes.

Tries to match a request with a set of routes.

Parameters

$request
Symfony\Component\HttpFoundation\Request
$request The request to match

Returns

array
An array of parameters

Throws

ResourceNotFoundException
If no matching resource could be found
MethodNotAllowedException
If a matching resource was found but the request method is not allowed

Implementation of

Symfony\Component\Routing\Matcher\RequestMatcherInterface::matchRequest()
public Symfony\Component\Routing\Matcher\UrlMatcherInterface
# getMatcher( )

Gets the UrlMatcher instance associated with this Router.

Gets the UrlMatcher instance associated with this Router.

Returns

Symfony\Component\Routing\Matcher\UrlMatcherInterface
A UrlMatcherInterface instance
public Symfony\Component\Routing\Generator\UrlGeneratorInterface
# getGenerator( )

Gets the UrlGenerator instance associated with this Router.

Gets the UrlGenerator instance associated with this Router.

Returns

Symfony\Component\Routing\Generator\UrlGeneratorInterface
A UrlGeneratorInterface instance
public
# addExpressionLanguageProvider( Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface $provider )
Constants inherited from Symfony\Component\Routing\Generator\UrlGeneratorInterface
ABSOLUTE_PATH, ABSOLUTE_URL, NETWORK_PATH, RELATIVE_PATH
Properties summary
protected Symfony\Component\Routing\Matcher\UrlMatcherInterface|null $matcher
#
protected Symfony\Component\Routing\Generator\UrlGeneratorInterface|null $generator
#
protected Symfony\Component\Routing\RequestContext $context
#
protected Symfony\Component\Config\Loader\LoaderInterface $loader
#
protected Symfony\Component\Routing\RouteCollection|null $collection
#
protected mixed $resource
#
protected array $options array()
#
protected Psr\Log\LoggerInterface|null $logger
#
Ratchet API documentation generated by ApiGen 2.8.0