Skip to content
The Routing component maps an HTTP request to a set of configuration variables.
PHP
Branch: master
Clone or download

Latest commit

nicolas-grekas Merge branch '5.1'
* 5.1:
  Fix abstract method name in PHP doc block
  Various cleanups
  [HttpClient] fix issues in tests
  Fixes sprintf(): Too few arguments in form transformer
  [Console] Fix QuestionHelper::disableStty()
  [Validator] Use Mime component to determine mime type for file validator
  validate subforms in all validation groups
  Update Hungarian translations
  Add meaningful message when Process is not installed (ProcessHelper)
  [Messenger] Change the default notify timeout value for PostgreSQL
  [PropertyAccess] Fix TypeError parsing again.
  [TwigBridge] fix fallback html-to-txt body converter
  [Security/Http] fix merge
  [ErrorHandler] fix setting $trace to null in FatalError
  [Form] add missing Czech validators translation
  [Validator] add missing Czech translations
  never directly validate Existence (Required/Optional) constraints
Latest commit 3fccb23 May 30, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Annotation Merge branch '5.0' Apr 21, 2020
DependencyInjection Merge branch '3.4' into 4.1 Jan 16, 2019
Exception Allow \Throwable $previous everywhere Nov 12, 2019
Generator Merge branch '4.4' into 5.0 Jan 4, 2020
Loader Merge branch '5.0' into 5.1 May 30, 2020
Matcher [Routing][FrameworkBundle] Allow using env() in route conditions Feb 25, 2020
Tests Merge branch '5.0' Apr 21, 2020
.gitattributes add missing gitattributes for phpunit-bridge Mar 27, 2020
.gitignore Added missing files .gitignore Jul 21, 2013
CHANGELOG.md [FrameworkBundle] Allow configuring the default base URI with a DSN May 4, 2020
CompiledRoute.php Replace @return annotation by return type in final classes Jun 22, 2019
LICENSE Update year in license files Jan 1, 2020
README.md Add installation and minimal example to README Mar 28, 2020
RequestContext.php [FrameworkBundle] use the router context by default for assets May 4, 2020
RequestContextAwareInterface.php [DI] minor docblock fixes Oct 24, 2017
Route.php fix merge (bis) Apr 21, 2020
RouteCollection.php Leverage trigger_deprecation() from symfony/deprecation-contracts Feb 8, 2020
RouteCollectionBuilder.php Leverage trigger_deprecation() from symfony/deprecation-contracts Feb 8, 2020
RouteCompiler.php fix merge (bis) Apr 21, 2020
RouteCompilerInterface.php [DI] minor docblock fixes Oct 24, 2017
Router.php Merge branch '4.4' into 5.0 Dec 12, 2019
RouterInterface.php [Routing] added a warning about the getRouteCollection() method Aug 4, 2019
composer.json Merge branch '5.1' May 20, 2020
phpunit.xml.dist Bump phpunit XSD version to 5.2 Nov 11, 2018

README.md

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

You can’t perform that action at this time.