hydra-sql/vendor/symfony/routing
2022-04-07 13:06:23 +02:00
..
Annotation Ajout des vendor 2022-04-07 13:06:23 +02:00
DependencyInjection Ajout des vendor 2022-04-07 13:06:23 +02:00
Exception Ajout des vendor 2022-04-07 13:06:23 +02:00
Generator Ajout des vendor 2022-04-07 13:06:23 +02:00
Loader Ajout des vendor 2022-04-07 13:06:23 +02:00
Matcher Ajout des vendor 2022-04-07 13:06:23 +02:00
Alias.php Ajout des vendor 2022-04-07 13:06:23 +02:00
CHANGELOG.md Ajout des vendor 2022-04-07 13:06:23 +02:00
CompiledRoute.php Ajout des vendor 2022-04-07 13:06:23 +02:00
composer.json Ajout des vendor 2022-04-07 13:06:23 +02:00
LICENSE Ajout des vendor 2022-04-07 13:06:23 +02:00
README.md Ajout des vendor 2022-04-07 13:06:23 +02:00
RequestContext.php Ajout des vendor 2022-04-07 13:06:23 +02:00
RequestContextAwareInterface.php Ajout des vendor 2022-04-07 13:06:23 +02:00
Route.php Ajout des vendor 2022-04-07 13:06:23 +02:00
RouteCollection.php Ajout des vendor 2022-04-07 13:06:23 +02:00
RouteCollectionBuilder.php Ajout des vendor 2022-04-07 13:06:23 +02:00
RouteCompiler.php Ajout des vendor 2022-04-07 13:06:23 +02:00
RouteCompilerInterface.php Ajout des vendor 2022-04-07 13:06:23 +02:00
Router.php Ajout des vendor 2022-04-07 13:06:23 +02:00
RouterInterface.php Ajout des vendor 2022-04-07 13:06:23 +02:00

Routing Component

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

Getting Started

$ composer require symfony/routing
use App\Controller\BlogController;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

$route = new Route('/blog/{slug}', ['_controller' => BlogController::class]);
$routes = new RouteCollection();
$routes->add('blog_show', $route);

$context = new RequestContext();

// Routing can match routes with incoming requests
$matcher = new UrlMatcher($routes, $context);
$parameters = $matcher->match('/blog/lorem-ipsum');
// $parameters = [
//     '_controller' => 'App\Controller\BlogController',
//     'slug' => 'lorem-ipsum',
//     '_route' => 'blog_show'
// ]

// Routing can also generate URLs for a given route
$generator = new UrlGenerator($routes, $context);
$url = $generator->generate('blog_show', [
    'slug' => 'my-blog-post',
]);
// $url = '/blog/my-blog-post'

Resources