Heimdall/vendor/symfony/routing
2022-03-10 11:54:29 +00:00
..
Annotation Update to laravel 7 2022-03-10 11:54:29 +00:00
DependencyInjection Update to laravel 7 2022-03-10 11:54:29 +00:00
Exception Update to laravel 7 2022-03-10 11:54:29 +00:00
Generator Update to laravel 7 2022-03-10 11:54:29 +00:00
Loader Update to laravel 7 2022-03-10 11:54:29 +00:00
Matcher Update to laravel 7 2022-03-10 11:54:29 +00:00
Alias.php Update to laravel 7 2022-03-10 11:54:29 +00:00
CHANGELOG.md Update to laravel 7 2022-03-10 11:54:29 +00:00
CompiledRoute.php Update to laravel 7 2022-03-10 11:54:29 +00:00
composer.json Update to laravel 7 2022-03-10 11:54:29 +00:00
LICENSE Update to laravel 7 2022-03-10 11:54:29 +00:00
README.md Update to laravel 7 2022-03-10 11:54:29 +00:00
RequestContext.php Update to laravel 7 2022-03-10 11:54:29 +00:00
RequestContextAwareInterface.php Update to laravel 7 2022-03-10 11:54:29 +00:00
Route.php Update to laravel 7 2022-03-10 11:54:29 +00:00
RouteCollection.php Update to laravel 7 2022-03-10 11:54:29 +00:00
RouteCollectionBuilder.php Update to laravel 7 2022-03-10 11:54:29 +00:00
RouteCompiler.php Update to laravel 7 2022-03-10 11:54:29 +00:00
RouteCompilerInterface.php Update to laravel 7 2022-03-10 11:54:29 +00:00
Router.php Update to laravel 7 2022-03-10 11:54:29 +00:00
RouterInterface.php Update to laravel 7 2022-03-10 11:54:29 +00: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