13 KiB
CHANGELOG
6.2
- Add
Requirement::POSITIVE_INTfor common ids and pagination
6.1
- Add
getMissingParametersandgetRouteNamemethods onMissingMandatoryParametersException - Allow using UTF-8 parameter names
- Support the
attributetype (alias ofannotation) in annotation loaders - Already encoded slashes are not decoded nor double-encoded anymore when generating URLs (query parameters)
- Add
EnumRequirementto help generate route requirements from a\BackedEnum - Add
Requirement, a collection of universal regular-expression constants to use as route parameter requirements - Add
paramsvariable to condition expression - Deprecate not passing route parameters as the fourth argument to
UrlMatcher::handleRouteRequirements()
5.3
- Already encoded slashes are not decoded nor double-encoded anymore when generating URLs
- Add support for per-env configuration in XML and Yaml loaders
- Deprecate creating instances of the
Routeannotation class by passing an array of parameters - Add
RoutingConfigurator::env()to get the current environment
5.2.0
- Added support for inline definition of requirements and defaults for host
- Added support for
\Aand\zas regex start and end for route requirement - Added support for
#[Route]attributes
5.1.0
- added the protected method
PhpFileLoader::callConfigurator()as extension point to ease custom routing configuration - deprecated
RouteCollectionBuilderin favor ofRoutingConfigurator. - added "priority" option to annotated routes
- added argument
$prioritytoRouteCollection::add() - deprecated the
RouteCompiler::REGEX_DELIMITERconstant - added
ExpressionLanguageProviderto expose extra functions to route conditions - added support for a
statelesskeyword for configuring route stateless in PHP, YAML and XML configurations. - added the "hosts" option to be able to configure the host per locale.
- added
RequestContext::fromUri()to ease building the default context
5.0.0
- removed
PhpGeneratorDumperandPhpMatcherDumper - removed
generator_base_class,generator_cache_class,matcher_base_classandmatcher_cache_classrouter options Serializableimplementing methods forRouteandCompiledRouteare final- removed referencing service route loaders with a single colon
- Removed
ServiceRouterLoaderandObjectRouteLoader.
4.4.0
- Deprecated
ServiceRouterLoaderin favor ofContainerLoader. - Deprecated
ObjectRouteLoaderin favor ofObjectLoader. - Added a way to exclude patterns of resources from being imported by the
import()method
4.3.0
- added
CompiledUrlMatcherandCompiledUrlMatcherDumper - added
CompiledUrlGeneratorandCompiledUrlGeneratorDumper - deprecated
PhpGeneratorDumperandPhpMatcherDumper - deprecated
generator_base_class,generator_cache_class,matcher_base_classandmatcher_cache_classrouter options Serializableimplementing methods forRouteandCompiledRouteare marked as@internaland@final. Instead of overwriting them, use__serializeand__unserializeas extension points which are forward compatible with the new serialization methods in PHP 7.4.- exposed
utf8Route option, defaults "locale" and "format" in configuration loaders and configurators - added support for invokable service route loaders
4.2.0
- added fallback to cultureless locale for internationalized routes
4.0.0
- dropped support for using UTF-8 route patterns without using the
utf8option - dropped support for using UTF-8 route requirements without using the
utf8option
3.4.0
- Added
NoConfigurationException. - Added the possibility to define a prefix for all routes of a controller via @Route(name="prefix_")
- Added support for prioritized routing loaders.
- Add matched and default parameters to redirect responses
- Added support for a
controllerkeyword for configuring route controllers in YAML and XML configurations.
3.3.0
- [DEPRECATION] Class parameters have been deprecated and will be removed in 4.0.
- router.options.generator_class
- router.options.generator_base_class
- router.options.generator_dumper_class
- router.options.matcher_class
- router.options.matcher_base_class
- router.options.matcher_dumper_class
- router.options.matcher.cache_class
- router.options.generator.cache_class
3.2.0
- Added support for
bool,int,float,string,listandmapdefaults in XML configurations. - Added support for UTF-8 requirements
2.8.0
-
allowed specifying a directory to recursively load all routing configuration files it contains
-
Added ObjectRouteLoader and ServiceRouteLoader that allow routes to be loaded by calling a method on an object/service.
-
[DEPRECATION] Deprecated the hardcoded value for the
$referenceTypeargument of theUrlGeneratorInterface::generatemethod. Use the constants defined in theUrlGeneratorInterfaceinstead.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);
2.5.0
- [DEPRECATION] The
ApacheMatcherDumperandApacheUrlMatcherwere 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.
2.3.0
- added RequestContext::getQueryString()
2.2.0
-
[DEPRECATION] Several route settings have been renamed (the old ones will be removed in 3.0):
- The
patternsetting for a route has been deprecated in favor ofpath - The
_schemeand_methodrequirements have been moved to theschemesandmethodssettings
Before:
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'); - The
-
[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
addCollectionfrom 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()andRouteCollection::getRoot()have been deprecated and will be removed in Symfony 2.3. -
[BC BREAK] Misusing the
RouteCollection::addPrefixmethod to add defaults, requirements or options without adding a prefix is not supported anymore. So if you calledaddPrefixwith an empty prefix or/only (both have no relevance), likeaddPrefix('', $defaultsArray, $requirementsArray, $optionsArray)you need to use the new dedicated methodsaddDefaults($defaultsArray),addRequirements($requirementsArray)oraddOptions($optionsArray)instead. -
[DEPRECATION] The
$optionsparameter toRouteCollection::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 useaddOptions(). -
[DEPRECATION] The method
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. -
[DEPRECATION]
RouteCollection::addCollection(RouteCollection $collection)should now only be used with a single parameter. The other params$prefix,$default,$requirementsand$optionswill still work, but have been deprecated. TheaddPrefixmethod should be used for this use-case instead. Before:$parentCollection->addCollection($collection, '/prefix', [...], [...])After:$collection->addPrefix('/prefix', [...], [...]); $parentCollection->addCollection($collection); -
added support for the method default argument values when defining a @Route
-
Adjacent placeholders without separator work now, e.g.
/{x}{y}{z}.{_format}. -
Characters that function as separator between placeholders are now whitelisted to fix routes with normal text around a variable, e.g.
/prefix{var}suffix. -
[BC BREAK] The default requirement of a variable has been changed slightly. Previously it disallowed the previous and the next char around a variable. Now it disallows the slash (
/) 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. -
The default requirement now uses possessive quantifiers when possible which improves matching performance by up to 20% because it prevents backtracking when it's not needed.
-
The ConfigurableRequirementsInterface can now also be used to disable the requirements check on URL generation completely by calling
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). -
There is no restriction on the route name anymore. So non-alphanumeric characters are now also allowed.
-
[BC BREAK]
RouteCompilerInterface::compile(Route $route)was made static (only relevant if you implemented your own RouteCompiler). -
Added possibility to generate relative paths and network paths in the UrlGenerator, e.g. "../parent-file" and "//example.com/dir/file". The third parameter in
UrlGeneratorInterface::generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)now accepts more values and you should use the constants defined inUrlGeneratorInterfacefor claritiy. The old method calls with a Boolean parameter will continue to work because they equal the signature using the constants.
2.1.0
- added RequestMatcherInterface
- added RequestContext::fromRequest()
- the UrlMatcher does not throw a \LogicException anymore when the required scheme is not the current one
- added TraceableUrlMatcher
- added the possibility to define options, default values and requirements for placeholders in prefix, including imported routes
- added RouterInterface::getRouteCollection
- [BC BREAK] the UrlMatcher urldecodes the route parameters only once, they
were decoded twice before. Note that the
urldecode()calls have been changed for a singlerawurldecode()in order to support+for input paths. - added RouteCollection::getRoot method to retrieve the root of a RouteCollection tree
- [BC BREAK] made RouteCollection::setParent private which could not have been used anyway without creating inconsistencies
- [BC BREAK] RouteCollection::remove also removes a route from parent collections (not only from its children)
- added ConfigurableRequirementsInterface that allows to disable exceptions (and generate empty URLs instead) when generating a route with an invalid parameter value