Symfony\Component\Routing\Loader\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()
{
}
}
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
class AnnotationClassLoader
implements
LoaderInterface
{
- // members
- protected Reader $reader;
- protected string $routeAnnotationClass;
- protected integer $defaultRouteIndex;
- // methods
- public void __construct()
- public void setRouteAnnotationClass()
- public RouteCollection load()
- protected void addRoute()
- public void supports()
- public void setResolver()
- public void getResolver()
- protected string getDefaultRouteName()
- protected abstract void configureRoute()
Hierarchy
Extended by
Implements
Members
protected
- $defaultRouteIndex — integer
- $reader — Doctrine\Common\Annotations\Reader
- $routeAnnotationClass — string
Methods
protected
- addRoute()
- configureRoute()
- getDefaultRouteName() — Gets the default route name for a class method.
public
- __construct() — Constructor.
- getResolver() — {@inheritdoc}
- load() — Loads from annotations from a class.
- setResolver() — {@inheritdoc}
- setRouteAnnotationClass() — Sets the annotation class to read route properties from.
- supports() — {@inheritdoc}