7 * Added `NoConfigurationException`.
8 * Added the possibility to define a prefix for all routes of a controller via @Route(name="prefix_")
9 * Added support for prioritized routing loaders.
10 * Add matched and default parameters to redirect responses
11 * Added support for a `controller` keyword for configuring route controllers in YAML and XML configurations.
16 * [DEPRECATION] Class parameters have been deprecated and will be removed in 4.0.
17 * router.options.generator_class
18 * router.options.generator_base_class
19 * router.options.generator_dumper_class
20 * router.options.matcher_class
21 * router.options.matcher_base_class
22 * router.options.matcher_dumper_class
23 * router.options.matcher.cache_class
24 * router.options.generator.cache_class
29 * Added support for `bool`, `int`, `float`, `string`, `list` and `map` defaults in XML configurations.
30 * Added support for UTF-8 requirements
35 * allowed specifying a directory to recursively load all routing configuration files it contains
36 * Added ObjectRouteLoader and ServiceRouteLoader that allow routes to be loaded
37 by calling a method on an object/service.
38 * [DEPRECATION] Deprecated the hardcoded value for the `$referenceType` argument of the `UrlGeneratorInterface::generate` method.
39 Use the constants defined in the `UrlGeneratorInterface` instead.
44 $router->generate('blog_show', array('slug' => 'my-blog-post'), true);
50 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
52 $router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL);
58 * [DEPRECATION] The `ApacheMatcherDumper` and `ApacheUrlMatcher` were deprecated and
59 will be removed in Symfony 3.0, since the performance gains were minimal and
60 it's hard to replicate the behaviour of PHP implementation.
65 * added RequestContext::getQueryString()
70 * [DEPRECATION] Several route settings have been renamed (the old ones will be removed in 3.0):
72 * The `pattern` setting for a route has been deprecated in favor of `path`
73 * The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings
79 pattern: /article/{id}
80 requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' }
84 <route id="article_edit" pattern="/article/{id}">
85 <requirement key="_method">POST|PUT</requirement>
86 <requirement key="_scheme">https</requirement>
87 <requirement key="id">\d+</requirement>
93 $route->setPattern('/article/{id}');
94 $route->setRequirement('_method', 'POST|PUT');
95 $route->setRequirement('_scheme', 'https');
105 requirements: { 'id': '\d+' }
109 <route id="article_edit" pattern="/article/{id}" methods="POST PUT" schemes="https">
110 <requirement key="id">\d+</requirement>
115 $route = new Route();
116 $route->setPath('/article/{id}');
117 $route->setMethods(array('POST', 'PUT'));
118 $route->setSchemes('https');
121 * [BC BREAK] RouteCollection does not behave like a tree structure anymore but as
122 a flat array of Routes. So when using PHP to build the RouteCollection, you must
123 make sure to add routes to the sub-collection before adding it to the parent
124 collection (this is not relevant when using YAML or XML for Route definitions).
129 $rootCollection = new RouteCollection();
130 $subCollection = new RouteCollection();
131 $rootCollection->addCollection($subCollection);
132 $subCollection->add('foo', new Route('/foo'));
138 $rootCollection = new RouteCollection();
139 $subCollection = new RouteCollection();
140 $subCollection->add('foo', new Route('/foo'));
141 $rootCollection->addCollection($subCollection);
144 Also one must call `addCollection` from the bottom to the top hierarchy.
145 So the correct sequence is the following (and not the reverse):
148 $childCollection->addCollection($grandchildCollection);
149 $rootCollection->addCollection($childCollection);
152 * [DEPRECATION] The methods `RouteCollection::getParent()` and `RouteCollection::getRoot()`
153 have been deprecated and will be removed in Symfony 2.3.
154 * [BC BREAK] Misusing the `RouteCollection::addPrefix` method to add defaults, requirements
155 or options without adding a prefix is not supported anymore. So if you called `addPrefix`
156 with an empty prefix or `/` only (both have no relevance), like
157 `addPrefix('', $defaultsArray, $requirementsArray, $optionsArray)`
158 you need to use the new dedicated methods `addDefaults($defaultsArray)`,
159 `addRequirements($requirementsArray)` or `addOptions($optionsArray)` instead.
160 * [DEPRECATION] The `$options` parameter to `RouteCollection::addPrefix()` has been deprecated
161 because adding options has nothing to do with adding a path prefix. If you want to add options
162 to all child routes of a RouteCollection, you can use `addOptions()`.
163 * [DEPRECATION] The method `RouteCollection::getPrefix()` has been deprecated
164 because it suggested that all routes in the collection would have this prefix, which is
165 not necessarily true. On top of that, since there is no tree structure anymore, this method
166 is also useless. Don't worry about performance, prefix optimization for matching is still done
167 in the dumper, which was also improved in 2.2.0 to find even more grouping possibilities.
168 * [DEPRECATION] `RouteCollection::addCollection(RouteCollection $collection)` should now only be
169 used with a single parameter. The other params `$prefix`, `$default`, `$requirements` and `$options`
170 will still work, but have been deprecated. The `addPrefix` method should be used for this
172 Before: `$parentCollection->addCollection($collection, '/prefix', array(...), array(...))`
175 $collection->addPrefix('/prefix', array(...), array(...));
176 $parentCollection->addCollection($collection);
178 * added support for the method default argument values when defining a @Route
179 * Adjacent placeholders without separator work now, e.g. `/{x}{y}{z}.{_format}`.
180 * Characters that function as separator between placeholders are now whitelisted
181 to fix routes with normal text around a variable, e.g. `/prefix{var}suffix`.
182 * [BC BREAK] The default requirement of a variable has been changed slightly.
183 Previously it disallowed the previous and the next char around a variable. Now
184 it disallows the slash (`/`) and the next char. Using the previous char added
185 no value and was problematic because the route `/index.{_format}` would be
186 matched by `/index.ht/ml`.
187 * The default requirement now uses possessive quantifiers when possible which
188 improves matching performance by up to 20% because it prevents backtracking
189 when it's not needed.
190 * The ConfigurableRequirementsInterface can now also be used to disable the requirements
191 check on URL generation completely by calling `setStrictRequirements(null)`. It
192 improves performance in production environment as you should know that params always
193 pass the requirements (otherwise it would break your link anyway).
194 * There is no restriction on the route name anymore. So non-alphanumeric characters
195 are now also allowed.
196 * [BC BREAK] `RouteCompilerInterface::compile(Route $route)` was made static
197 (only relevant if you implemented your own RouteCompiler).
198 * Added possibility to generate relative paths and network paths in the UrlGenerator, e.g.
199 "../parent-file" and "//example.com/dir/file". The third parameter in
200 `UrlGeneratorInterface::generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)`
201 now accepts more values and you should use the constants defined in `UrlGeneratorInterface` for
202 claritiy. The old method calls with a Boolean parameter will continue to work because they
203 equal the signature using the constants.
208 * added RequestMatcherInterface
209 * added RequestContext::fromRequest()
210 * the UrlMatcher does not throw a \LogicException anymore when the required
211 scheme is not the current one
212 * added TraceableUrlMatcher
213 * added the possibility to define options, default values and requirements
214 for placeholders in prefix, including imported routes
215 * added RouterInterface::getRouteCollection
216 * [BC BREAK] the UrlMatcher urldecodes the route parameters only once, they
217 were decoded twice before. Note that the `urldecode()` calls have been
218 changed for a single `rawurldecode()` in order to support `+` for input
220 * added RouteCollection::getRoot method to retrieve the root of a
222 * [BC BREAK] made RouteCollection::setParent private which could not have
223 been used anyway without creating inconsistencies
224 * [BC BREAK] RouteCollection::remove also removes a route from parent
225 collections (not only from its children)
226 * added ConfigurableRequirementsInterface that allows to disable exceptions
227 (and generate empty URLs instead) when generating a route with an invalid