AnnotationClassLoader
abstract class AnnotationClassLoader implements LoaderInterface
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()
{
}
}
Properties
protected | $reader | ||
protected string | $routeAnnotationClass | ||
protected int | $defaultRouteIndex |
Methods
No description
Sets the annotation class to read route properties from.
Loads from annotations from a class.
No description
Returns whether this class supports the given resource.
Gets the loader resolver.
Gets the default route name for a class method.
No description
No description
Details
protected
addRoute(RouteCollection $collection, $annot, $globals, ReflectionClass $class, ReflectionMethod $method)
bool
supports(mixed $resource, string|null $type = null)
Returns whether this class supports the given resource.
protected string
getDefaultRouteName(ReflectionClass $class, ReflectionMethod $method)
Gets the default route name for a class method.