This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Routing
Nicolas Grekas 20ecf91d52 feature #24180 [Routing] Add PHP fluent DSL for configuring routes (nicolas-grekas)
This PR was merged into the 3.4 branch.

Discussion
----------

[Routing] Add PHP fluent DSL for configuring routes

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

If we add a PHP DSL for DI config (#23834), we must have a similar one for routing. Here it is. See fixtures.

So, you always start with a `RoutingConfigurator $routes`, which allows you to:
```php
$routes->add($name, $path); // adds a route
$routes->import($resource, $type = null, $ignoreErrors = false); // imports routes
$routes->collection($name = ''); // starts a collection, all *names* might be prefixed
```

then
- for "import" and "collection", you can `->prefix($path)`;
- for "add" and "collection", you can fluently "add" several times;
- for "collection" you add sub"`->collection()`";
- and on all, you can configure the route(s) with:
```php
->defaults(array $defaults)
->requirements(array $requirements)
->options(array $options)
->condition($condition)
->host($pattern)
->schemes(array $schemes)
->methods(array $methods)
->controller($controller)
```

Commits
-------

f433c9a [Routing] Add PHP fluent DSL for configuring routes
2017-09-20 15:01:12 +02:00
..
Annotation Merge branch '2.8' into 3.0 2016-06-29 07:40:00 +02:00
DependencyInjection Automatically enable the routing annotation loader 2017-06-07 12:20:52 +02:00
Exception remove api tags from code 2015-09-28 19:11:22 +02:00
Generator [Routing] Fixed route generation with fragment defined as defaults 2016-09-21 17:48:58 +03:00
Loader feature #24180 [Routing] Add PHP fluent DSL for configuring routes (nicolas-grekas) 2017-09-20 15:01:12 +02:00
Matcher Merge branch '3.3' into 3.4 2017-09-15 12:12:22 +02:00
Tests feature #24180 [Routing] Add PHP fluent DSL for configuring routes (nicolas-grekas) 2017-09-20 15:01:12 +02:00
.gitignore
CHANGELOG.md [Routing] added the possibility to define a prefix for all routes of a controller 2017-08-29 15:38:20 -07:00
CompiledRoute.php Merge branch '3.2' into 3.3 2017-06-02 11:51:43 +02:00
composer.json Merge branch '3.3' into 3.4 2017-08-03 11:34:20 +02:00
LICENSE updated LICENSE year 2017-01-02 12:30:00 -08:00
phpunit.xml.dist fail when detecting risky tests 2017-04-12 09:39:27 +02:00
README.md Updated all the README files 2016-03-04 08:12:06 +01:00
RequestContext.php fixed @return when returning this or static 2016-12-27 08:23:47 +01:00
RequestContextAwareInterface.php remove api tags from code 2015-09-28 19:11:22 +02:00
Route.php [Routing] Revert the change in [#b42018] with respect to Routing/Route.php 2017-06-13 10:11:59 -07:00
RouteCollection.php add docblock type elements to support newly added IteratorAggregate::getIterator PhpStorm support 2016-06-17 14:42:34 +02:00
RouteCollectionBuilder.php added a more specialized exception for a better error message 2017-04-11 13:45:43 -07:00
RouteCompiler.php Merge branch '2.8' into 3.3 2017-09-11 13:43:11 -07:00
RouteCompilerInterface.php
Router.php Merge branch '2.8' into 3.1 2016-08-16 07:58:24 -07:00
RouterInterface.php

Routing Component

The Routing component maps an HTTP request to a set of configuration variables.

Resources