GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - symfony/routing: Maps an HTTP request to a set of configuration variables

BranchesTags
Open more actions menu

Latest commit

 

History

2,856 Commits
2,856 Commits

Folders and files

NameName
Last commit message
Last commit date
Attribute
Attribute
 
 
CacheWarmer
CacheWarmer
 
 
Command
Command
 
 
Controller
Controller
 
 
DependencyInjection
DependencyInjection
 
 
Exception
Exception
 
 
Generator
Generator
 
 
Loader
Loader
 
 
Matcher
Matcher
 
 
Requirement
Requirement
 
 
Resources/config
Resources/config
 
 
Tests
Tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
Alias.php
Alias.php
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CompiledRoute.php
CompiledRoute.php
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
RequestContext.php
RequestContext.php
 
 
RequestContextAwareInterface.php
RequestContextAwareInterface.php
 
 
Route.php
Route.php
 
 
RouteCollection.php
RouteCollection.php
 
 
RouteCompiler.php
RouteCompiler.php
 
 
RouteCompilerInterface.php
RouteCompilerInterface.php
 
 
Router.php
Router.php
 
 
RouterBundle.php
RouterBundle.php
 
 
RouterInterface.php
RouterInterface.php
 
 
composer.json
composer.json
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

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

This package is looking for a backer.

Help Symfony by sponsoring its development!

Resources

  • Documentation
  • Contributing
  • Report issues and send Pull Requests in the main Symfony repository

About

Maps an HTTP request to a set of configuration variables

symfony.com/routing

Topics

componentphprouterroutingsymfonysymfony-componenturiurl

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

7.6k stars

Watchers

26 watching

Forks

92 forks
Report repository

Releases

Sponsor this project

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.