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 Route

A Route describes a route and its parameters.

Symfony\Component\Routing\Route implements Serializable
Namespace: Symfony\Component\Routing
Author: Fabien Potencier <fabien@symfony.com>
Author: Tobias Schultze <http://tobion.de>
Located at Route.php
Methods summary
public
# __construct( string $path, array $defaults = array(), array $requirements = array(), array $options = array(), string $host = '', string|array $schemes = array(), string|array $methods = array(), string $condition = '' )

Constructor.

Constructor.

Available options:
* compiler_class: A class name able to compile this route instance (RouteCompiler by default)

Parameters

$path
string
$path The path pattern to match
$defaults
array
$defaults An array of default parameter values
$requirements
array
$requirements An array of requirements for parameters (regexes)
$options
array
$options An array of options
$host
string
$host The host pattern to match
$schemes
string|array
$schemes A required URI scheme or an array of restricted schemes
$methods
string|array
$methods A required HTTP method or an array of restricted methods
$condition
string
$condition A condition that should evaluate to true for the route to match
public
# serialize( )

Implementation of

Serializable::serialize()
public
# unserialize( mixed $serialized )

Implementation of

Serializable::unserialize()
public string
# getPath( )

Returns the pattern for the path.

Returns the pattern for the path.

Returns

string
The path pattern
public mixed
# setPath( string $pattern )

Sets the pattern for the path.

Sets the pattern for the path.

This method implements a fluent interface.

Parameters

$pattern
string
$pattern The path pattern

Returns

mixed
$this
public string
# getHost( )

Returns the pattern for the host.

Returns the pattern for the host.

Returns

string
The host pattern
public mixed
# setHost( string $pattern )

Sets the pattern for the host.

Sets the pattern for the host.

This method implements a fluent interface.

Parameters

$pattern
string
$pattern The host pattern

Returns

mixed
$this
public array
# getSchemes( )

Returns the lowercased schemes this route is restricted to. So an empty array means that any scheme is allowed.

Returns the lowercased schemes this route is restricted to. So an empty array means that any scheme is allowed.

Returns

array
The schemes
public mixed
# setSchemes( string|array $schemes )

Sets the schemes (e.g. 'https') this route is restricted to. So an empty array means that any scheme is allowed.

Sets the schemes (e.g. 'https') this route is restricted to. So an empty array means that any scheme is allowed.

This method implements a fluent interface.

Parameters

$schemes
string|array
$schemes The scheme or an array of schemes

Returns

mixed
$this
public boolean
# hasScheme( string $scheme )

Checks if a scheme requirement has been set.

Checks if a scheme requirement has been set.

Parameters

$scheme
string
$scheme

Returns

boolean
true if the scheme requirement exists, otherwise false
public array
# getMethods( )

Returns the uppercased HTTP methods this route is restricted to. So an empty array means that any method is allowed.

Returns the uppercased HTTP methods this route is restricted to. So an empty array means that any method is allowed.

Returns

array
The methods
public mixed
# setMethods( string|array $methods )

Sets the HTTP methods (e.g. 'POST') this route is restricted to. So an empty array means that any method is allowed.

Sets the HTTP methods (e.g. 'POST') this route is restricted to. So an empty array means that any method is allowed.

This method implements a fluent interface.

Parameters

$methods
string|array
$methods The method or an array of methods

Returns

mixed
$this
public array
# getOptions( )

Returns the options.

Returns the options.

Returns

array
The options
public mixed
# setOptions( array $options )

Sets the options.

Sets the options.

This method implements a fluent interface.

Parameters

$options
array
$options The options

Returns

mixed
$this
public mixed
# addOptions( array $options )

Adds options.

Adds options.

This method implements a fluent interface.

Parameters

$options
array
$options The options

Returns

mixed
$this
public mixed
# setOption( string $name, mixed $value )

Sets an option value.

Sets an option value.

This method implements a fluent interface.

Parameters

$name
string
$name An option name
$value
mixed
$value The option value

Returns

mixed
$this
public mixed
# getOption( string $name )

Get an option value.

Get an option value.

Parameters

$name
string
$name An option name

Returns

mixed
The option value or null when not given
public boolean
# hasOption( string $name )

Checks if an option has been set.

Checks if an option has been set.

Parameters

$name
string
$name An option name

Returns

boolean
true if the option is set, false otherwise
public array
# getDefaults( )

Returns the defaults.

Returns the defaults.

Returns

array
The defaults
public mixed
# setDefaults( array $defaults )

Sets the defaults.

Sets the defaults.

This method implements a fluent interface.

Parameters

$defaults
array
$defaults The defaults

Returns

mixed
$this
public mixed
# addDefaults( array $defaults )

Adds defaults.

Adds defaults.

This method implements a fluent interface.

Parameters

$defaults
array
$defaults The defaults

Returns

mixed
$this
public mixed
# getDefault( string $name )

Gets a default value.

Gets a default value.

Parameters

$name
string
$name A variable name

Returns

mixed
The default value or null when not given
public boolean
# hasDefault( string $name )

Checks if a default value is set for the given variable.

Checks if a default value is set for the given variable.

Parameters

$name
string
$name A variable name

Returns

boolean
true if the default value is set, false otherwise
public mixed
# setDefault( string $name, mixed $default )

Sets a default value.

Sets a default value.

Parameters

$name
string
$name A variable name
$default
mixed
$default The default value

Returns

mixed
$this
public array
# getRequirements( )

Returns the requirements.

Returns the requirements.

Returns

array
The requirements
public mixed
# setRequirements( array $requirements )

Sets the requirements.

Sets the requirements.

This method implements a fluent interface.

Parameters

$requirements
array
$requirements The requirements

Returns

mixed
$this
public mixed
# addRequirements( array $requirements )

Adds requirements.

Adds requirements.

This method implements a fluent interface.

Parameters

$requirements
array
$requirements The requirements

Returns

mixed
$this
public string|null
# getRequirement( string $key )

Returns the requirement for the given key.

Returns the requirement for the given key.

Parameters

$key
string
$key The key

Returns

string|null
The regex or null when not given
public boolean
# hasRequirement( string $key )

Checks if a requirement is set for the given key.

Checks if a requirement is set for the given key.

Parameters

$key
string
$key A variable name

Returns

boolean
true if a requirement is specified, false otherwise
public mixed
# setRequirement( string $key, string $regex )

Sets a requirement for the given key.

Sets a requirement for the given key.

Parameters

$key
string
$key The key
$regex
string
$regex The regex

Returns

mixed
$this
public string
# getCondition( )

Returns the condition.

Returns the condition.

Returns

string
The condition
public mixed
# setCondition( string $condition )

Sets the condition.

Sets the condition.

This method implements a fluent interface.

Parameters

$condition
string
$condition The condition

Returns

mixed
$this
public Symfony\Component\Routing\CompiledRoute
# compile( )

Compiles the route.

Compiles the route.

Returns

Symfony\Component\Routing\CompiledRoute
A CompiledRoute instance

Throws

LogicException
If the Route cannot be compiled because the path or host pattern is invalid

See

RouteCompiler which is responsible for the compilation process
Ratchet API documentation generated by ApiGen 2.8.0