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

  • AnnotationClassLoader
  • AnnotationDirectoryLoader
  • AnnotationFileLoader
  • ClosureLoader
  • DirectoryLoader
  • ObjectRouteLoader
  • PhpFileLoader
  • RecursiveCallbackFilterIterator
  • XmlFileLoader
  • YamlFileLoader
  • Overview
  • Namespace
  • Class
  • Tree

Class AnnotationClassLoader

AnnotationClassLoader loads routing information from a PHP class and its methods.

You need to define an implementation for the getRouteDefaults() method. Most of the time, this method should define some PHP callable to be called for the route (a controller in MVC speak).

The @Route annotation can be set on the class (for global parameters), and on each method.

The @Route annotation main value is the route path. The annotation also recognizes several parameters: requirements, options, defaults, schemes, methods, host, and name. The name parameter is mandatory. Here is an example of how you should be able to use it:
/** * @Route("/Blog") * / class Blog { /** * @Route("/", name="blog_index") * / public function index() { }
/** * @Route("/{id}", name="blog_post", requirements = {"id" = "\d+"}) * / public function show() { } }

Symfony\Component\Routing\Loader\AnnotationClassLoader implements Symfony\Component\Config\Loader\LoaderInterface
Abstract
Namespace: Symfony\Component\Routing\Loader
Author: Fabien Potencier <fabien@symfony.com>
Located at Loader/AnnotationClassLoader.php
Methods summary
public
# __construct( Doctrine\Common\Annotations\Reader $reader )

Constructor.

Constructor.

Parameters

$reader
Doctrine\Common\Annotations\Reader
$reader
public
# setRouteAnnotationClass( string $class )

Sets the annotation class to read route properties from.

Sets the annotation class to read route properties from.

Parameters

$class
string
$class A fully-qualified class name
public Symfony\Component\Routing\RouteCollection
# load( string $class, string|null $type = null )

Loads from annotations from a class.

Loads from annotations from a class.

Parameters

$class
string
$class A class name
$type
string|null
$type The resource type

Returns

Symfony\Component\Routing\RouteCollection
A RouteCollection instance

Throws

InvalidArgumentException
When route can't be parsed
protected
# addRoute( Symfony\Component\Routing\RouteCollection $collection, mixed $annot, mixed $globals, ReflectionClass $class, ReflectionMethod $method )
public
# supports( mixed $resource, mixed $type = null )
public
# setResolver( Symfony\Component\Config\Loader\LoaderResolverInterface $resolver )
public
# getResolver( )
protected string
# getDefaultRouteName( ReflectionClass $class, ReflectionMethod $method )

Gets the default route name for a class method.

Gets the default route name for a class method.

Parameters

$class
ReflectionClass
$class
$method
ReflectionMethod
$method

Returns

string
protected
# getGlobals( ReflectionClass $class )
protected
# createRoute( mixed $path, mixed $defaults, mixed $requirements, mixed $options, mixed $host, mixed $schemes, mixed $methods, mixed $condition )
abstract protected
# configureRoute( Symfony\Component\Routing\Route $route, ReflectionClass $class, ReflectionMethod $method, mixed $annot )
Properties summary
protected Doctrine\Common\Annotations\Reader $reader
#
protected string $routeAnnotationClass 'Symfony\\Component\\Routing\\Annotation\\Route'
#
protected integer $defaultRouteIndex 0
#
Ratchet API documentation generated by ApiGen 2.8.0