MyGit
🚩收到GitHub仓库的更新通知

symfony/routing

Fork: 99 Star: 7540 (更新于 2024-04-24 18:57:34)

license: MIT

Language: PHP .

Maps an HTTP request to a set of configuration variables

最后发布版本: v7.0.6 ( 2024-04-03 14:19:33)

官方网址 GitHub网址

✨免费申请网站SSL证书,支持多域名和泛域名,点击查看

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.0 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-04-26 22:41:10)

2024-04-03 14:19:33 v7.0.6

2024-04-03 14:13:19 v6.4.6

2024-04-03 14:08:48 v5.4.38

2024-03-05 05:09:59 v7.0.5

2024-03-05 05:05:43 v6.4.5

2024-03-05 05:01:04 v5.4.37

2024-01-31 17:14:07 v7.0.3

2024-01-31 15:41:35 v6.4.3

2024-01-31 15:22:07 v6.3.12

2024-01-31 04:06:07 v5.4.35

主题(topics):

component, php, router, routing, symfony, symfony-component, uri, url

symfony/routing同语言 PHP最近更新仓库

2024-05-10 11:01:12 wp-graphql/wp-graphql

2024-05-10 00:12:03 andreaselia/laravel-api-to-postman

2024-05-09 11:10:21 firefly-iii/firefly-iii

2024-05-08 17:14:52 CakeDC/users

2024-05-07 16:30:06 jackalope/jackalope-doctrine-dbal

2024-05-06 12:00:32 symfony/maker-bundle