symfony/routing
Fork: 98 Star: 7590 (更新于 2024-11-01 10:15:41)
license: MIT
Language: PHP .
Maps an HTTP request to a set of configuration variables
最后发布版本: v6.4.12 ( 2024-09-21 14:09:21)
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'
Sponsor
The Routing component for Symfony 7.1 is backed by redirection.io.
redirection.io logs all your website’s HTTP traffic, and lets you fix errors with redirect rules in seconds. Give your marketing, SEO and IT teams the right tool to manage your website traffic efficiently!
Help Symfony by sponsoring its development!
Resources
最近版本更新:(数据更新于 2024-10-09 11:10:36)
2024-09-21 14:09:21 v6.4.12
2024-08-31 01:07:38 v7.1.4
2024-08-31 01:02:39 v6.4.11
2024-08-31 00:57:50 v5.4.43
2024-07-26 23:04:34 v7.1.3
2024-07-26 23:00:49 v7.0.10
2024-07-26 22:56:41 v6.4.10
2024-07-26 22:51:01 v5.4.42
2024-06-04 15:37:16 v7.1.1
2024-06-03 02:03:41 v7.0.8
主题(topics):
component, php, router, routing, symfony, symfony-component, uri, url
symfony/routing同语言 PHP最近更新仓库
2024-11-20 23:58:25 laravel/framework
2024-11-20 18:39:23 danielmiessler/SecLists
2024-11-16 21:54:23 w7corp/easywechat
2024-11-16 04:49:03 coollabsio/coolify
2024-11-13 23:19:14 symfony/symfony
2024-11-13 22:53:21 symfony/var-dumper