Skip to content

Commit 6651f59

Browse files
Merge branch '4.4' into 5.0
* 4.4: [PropertyAccess] fix tests [WebProfilerBundle] fix test remove assertions that can never be reached [PropertyAccess] Improve message of unitialized property in php 7.4 [HttpFoundation] Fixed session migration with custom cookie lifetime [HttpKernel][FrameworkBundle] fix compat with Debug component [Serializer] Remove unused variable Allow URL-encoded special characters in basic auth part of URLs [Serializer] Fix unitialized properties (from PHP 7.4.2) when serializing context for the cache key [Validator] Add missing Ukrainian and Russian translations Track session usage when setting the token [4.4][MonologBridge] Fix $level type No need to reconnect the bags to the session Support for Content Security Policy style-src-elem and script-src-elem in WebProfiler [PropertyInfo][ReflectionExtractor] Check the array mutator prefixes last when the property is singular [Security][Http][SwitchUserListener] Ignore all non existent username protection errors Add installation and minimal example to README
2 parents d98a95d + ed8bd70 commit 6651f59

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,48 @@ Routing Component
33

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

6+
Getting Started
7+
---------------
8+
9+
```
10+
$ composer require symfony/routing
11+
```
12+
13+
```php
14+
use App\Controller\BlogController;
15+
use Symfony\Component\Routing\Generator\UrlGenerator;
16+
use Symfony\Component\Routing\Matcher\UrlMatcher;
17+
use Symfony\Component\Routing\RequestContext;
18+
use Symfony\Component\Routing\Route;
19+
use Symfony\Component\Routing\RouteCollection;
20+
21+
$route = new Route('/blog/{slug}', ['_controller' => BlogController::class]);
22+
$routes = new RouteCollection();
23+
$routes->add('blog_show', $route);
24+
25+
$context = new RequestContext();
26+
27+
// Routing can match routes with incoming requests
28+
$matcher = new UrlMatcher($routes, $context);
29+
$parameters = $matcher->match('/blog/lorem-ipsum');
30+
// $parameters = [
31+
// '_controller' => 'App\Controller\BlogController',
32+
// 'slug' => 'lorem-ipsum',
33+
// '_route' => 'blog_show'
34+
// ]
35+
36+
// Routing can also generate URLs for a given route
37+
$generator = new UrlGenerator($routes, $context);
38+
$url = $generator->generate('blog_show', [
39+
'slug' => 'my-blog-post',
40+
]);
41+
// $url = '/blog/my-blog-post'
42+
```
43+
644
Resources
745
---------
846

9-
* [Documentation](https://symfony.com/doc/current/components/routing.html)
47+
* [Documentation](https://symfony.com/doc/current/routing.html)
1048
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
1149
* [Report issues](https://github.com/symfony/symfony/issues) and
1250
[send Pull Requests](https://github.com/symfony/symfony/pulls)

0 commit comments

Comments
 (0)