AttributeServicesLoader and RoutingControllerPass to auto-register routes from attributes on servicesUrlGenerator using _querySymfony\Component\Routing\Attribute\Route attribute$parameters to RequestContext’s constructorRoutesReference to help writing PHP configs using yaml-like array-shapesAnnotation namespace, use attributes instead#[Route] attributeRequirement::MONGODB_ID constant to validate MongoDB ObjectIDs in hexadecimal formatRequirement::UID_RFC9562 constant to validate UUIDs in the RFC 9562 formatAttributeClassLoader::$routeAnnotationClass property{foo:bar} syntax to define a mapping between a route parameter and its corresponding request attribute$routeParameters to UrlMatcher::handleRouteRequirements()AnnotationClassLoader, use AttributeClassLoader insteadAnnotationDirectoryLoader, use AttributeDirectoryLoader insteadAnnotationFileLoader, use AttributeFileLoader insteadAnnotationClassLoader::setResolver()AnnotationClassLoader to __construct(?string $env = null), passing an annotation reader as first argument is deprecatedAnnotationClassLoader, use AttributeClassLoader insteadAnnotationDirectoryLoader, use AttributeDirectoryLoader insteadAnnotationFileLoader, use AttributeFileLoader insteadAddExpressionLanguageProvidersPass (moved from FrameworkBundle)Annotation namespace to AttributeRequirement::POSITIVE_INT for common ids and paginationgetMissingParameters and getRouteName methods on MissingMandatoryParametersExceptionattribute type (alias of annotation) in annotation loadersEnumRequirement to help generate route requirements from a \BackedEnumRequirement, a collection of universal regular-expression constants to use as route parameter requirementsparams variable to condition expressionUrlMatcher::handleRouteRequirements()Route annotation class by passing an array of parametersRoutingConfigurator::env() to get the current environment\A and \z as regex start and end for route requirement#[Route] attributesPhpFileLoader::callConfigurator() as extension point to ease custom routing configurationRouteCollectionBuilder in favor of RoutingConfigurator.$priority to RouteCollection::add()RouteCompiler::REGEX_DELIMITER constantExpressionLanguageProvider to expose extra functions to route conditionsstateless keyword for configuring route stateless in PHP, YAML and XML configurations.RequestContext::fromUri() to ease building the default contextPhpGeneratorDumper and PhpMatcherDumpergenerator_base_class, generator_cache_class, matcher_base_class and matcher_cache_class router optionsSerializable implementing methods for Route and CompiledRoute are finalServiceRouterLoader and ObjectRouteLoader.ServiceRouterLoader in favor of ContainerLoader.ObjectRouteLoader in favor of ObjectLoader.import() methodCompiledUrlMatcher and CompiledUrlMatcherDumperCompiledUrlGenerator and CompiledUrlGeneratorDumperPhpGeneratorDumper and PhpMatcherDumpergenerator_base_class, generator_cache_class, matcher_base_class and matcher_cache_class router optionsSerializable implementing methods for Route and CompiledRoute are marked as @internal and @final.
Instead of overwriting them, use __serialize and __unserialize as extension points which are forward compatible
with the new serialization methods in PHP 7.4.utf8 Route option, defaults “locale” and “format” in configuration loaders and configuratorsutf8 optionutf8 optionNoConfigurationException.controller keyword for configuring route controllers in YAML and XML configurations.bool, int, float, string, list and map defaults in XML configurations.[DEPRECATION] Deprecated the hardcoded value for the $referenceType argument of the UrlGeneratorInterface::generate method.
Use the constants defined in the UrlGeneratorInterface instead.
Before:
$router->generate('blog_show', ['slug' => 'my-blog-post'], true);
After:
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
$router->generate('blog_show', ['slug' => 'my-blog-post'], UrlGeneratorInterface::ABSOLUTE_URL);
ApacheMatcherDumper and ApacheUrlMatcher were deprecated and
will be removed in Symfony 3.0, since the performance gains were minimal and
it’s hard to replicate the behavior of PHP implementation.[DEPRECATION] Several route settings have been renamed (the old ones will be removed in 3.0):
pattern setting for a route has been deprecated in favor of path_scheme and _method requirements have been moved to the schemes and methods settingsBefore:
article_edit:
pattern: /article/{id}
requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' }
<route id="article_edit" pattern="/article/{id}">
<requirement key="_method">POST|PUT</requirement>
<requirement key="_scheme">https</requirement>
<requirement key="id">\d+</requirement>
</route>
$route = new Route();
$route->setPattern('/article/{id}');
$route->setRequirement('_method', 'POST|PUT');
$route->setRequirement('_scheme', 'https');
After:
article_edit:
path: /article/{id}
methods: [POST, PUT]
schemes: https
requirements: { 'id': '\d+' }
<route id="article_edit" pattern="/article/{id}" methods="POST PUT" schemes="https">
<requirement key="id">\d+</requirement>
</route>
$route = new Route();
$route->setPath('/article/{id}');
$route->setMethods(['POST', 'PUT']);
$route->setSchemes('https');
[BC BREAK] RouteCollection does not behave like a tree structure anymore but as a flat array of Routes. So when using PHP to build the RouteCollection, you must make sure to add routes to the sub-collection before adding it to the parent collection (this is not relevant when using YAML or XML for Route definitions).
Before:
$rootCollection = new RouteCollection();
$subCollection = new RouteCollection();
$rootCollection->addCollection($subCollection);
$subCollection->add('foo', new Route('/foo'));
After:
$rootCollection = new RouteCollection();
$subCollection = new RouteCollection();
$subCollection->add('foo', new Route('/foo'));
$rootCollection->addCollection($subCollection);
Also one must call addCollection from the bottom to the top hierarchy.
So the correct sequence is the following (and not the reverse):
$childCollection->addCollection($grandchildCollection);
$rootCollection->addCollection($childCollection);
[DEPRECATION] The methods RouteCollection::getParent() and RouteCollection::getRoot()
have been deprecated and will be removed in Symfony 2.3.
RouteCollection::addPrefix method to add defaults, requirements
or options without adding a prefix is not supported anymore. So if you called addPrefix
with an empty prefix or / only (both have no relevance), like
addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)
you need to use the new dedicated methods addDefaults($defaultsArray),
addRequirements($requirementsArray) or addOptions($optionsArray) instead.$options parameter to RouteCollection::addPrefix() has been deprecated
because adding options has nothing to do with adding a path prefix. If you want to add options
to all child routes of a RouteCollection, you can use addOptions().RouteCollection::getPrefix() has been deprecated
because it suggested that all routes in the collection would have this prefix, which is
not necessarily true. On top of that, since there is no tree structure anymore, this method
is also useless. Don’t worry about performance, prefix optimization for matching is still done
in the dumper, which was also improved in 2.2.0 to find even more grouping possibilities.RouteCollection::addCollection(RouteCollection $collection) should now only be
used with a single parameter. The other params $prefix, $default, $requirements and $options
will still work, but have been deprecated. The addPrefix method should be used for this
use-case instead.
Before: $parentCollection->addCollection($collection, '/prefix', [...], [...])
After:
php
$collection->addPrefix('/prefix', [...], [...]);
$parentCollection->addCollection($collection);
/{x}{y}{z}.{_format}./prefix{var}suffix./) and the next char. Using the previous char added
no value and was problematic because the route /index.{_format} would be
matched by /index.ht/ml.setStrictRequirements(null). It
improves performance in production environment as you should know that params always
pass the requirements (otherwise it would break your link anyway).RouteCompilerInterface::compile(Route $route) was made static
(only relevant if you implemented your own RouteCompiler).UrlGeneratorInterface::generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
now accepts more values and you should use the constants defined in UrlGeneratorInterface for
claritiy. The old method calls with a Boolean parameter will continue to work because they
equal the signature using the constants.urldecode() calls have been
changed for a single rawurldecode() in order to support + for input
paths.