This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Routing
Fabien Potencier e7067cb771 Merge branch '2.5' into 2.6
* 2.5:
  Update filesystem readme.md to include exists method
  Add machine readable events
  [HttpKernel][2.6] Adding support for invokable controllers in the RequestDataCollector
  fixed typo
  [Translations] Added missing Hebrew language trans-unit sources
  [DependencyInjection] inlined factory not referenced
  Fixed case for empty folder
  Fixed whitespace control for password form widget
  [Routing] correctly initialize condition as string
2014-11-16 18:28:09 +01:00
..
Annotation Merge branch '2.3' into 2.4 2014-04-23 16:04:21 +02:00
Exception corrected English grammar (s/does not exists/does not exist) 2013-08-13 20:56:24 +01:00
Generator decodes some special chars in a URL query 2014-10-26 21:31:09 +01:00
Loader Merge branch '2.5' 2014-11-03 04:55:50 +01:00
Matcher Merge branch '2.5' 2014-10-26 08:46:28 +01:00
Tests Merge branch '2.5' 2014-11-03 04:55:50 +01:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md Merge branch '2.3' into 2.5 2014-10-01 07:50:18 +02:00
CompiledRoute.php [Routing] serialize the compiled route to speed things up 2014-10-27 15:27:32 +01:00
composer.json Merge branch '2.5' 2014-09-22 17:29:07 +02:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
phpunit.xml.dist removed defaults from PHPUnit configuration 2014-07-07 12:13:42 +02:00
README.md [Doc] Use Markdown syntax highlighting 2014-10-01 07:38:33 +02:00
RequestContext.php [Routing] unify fluent interface in RequestContext 2014-10-09 18:12:58 +02:00
RequestContextAwareInterface.php fixed CS 2012-07-09 14:54:20 +02:00
Route.php [Routing] correctly initialize condition as string 2014-11-03 21:24:10 +01:00
RouteCollection.php [Routing] added support for expression conditions in routes 2013-09-19 12:59:11 +02:00
RouteCompiler.php [Router] Cleanup 2014-10-13 14:38:27 +02:00
RouteCompilerInterface.php renamed hostname to host in the routing system (closes #6775) 2013-01-21 17:57:32 +01:00
Router.php Merge branch '2.5' 2014-10-26 08:46:28 +01:00
RouterInterface.php fixed CS 2012-07-09 14:54:20 +02:00

Routing Component

Routing associates a request with the code that will convert it to a response.

The example below demonstrates how you can set up a fully working routing system:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

$routes = new RouteCollection();
$routes->add('hello', new Route('/hello', array('controller' => 'foo')));

$context = new RequestContext();

// this is optional and can be done without a Request instance
$context->fromRequest(Request::createFromGlobals());

$matcher = new UrlMatcher($routes, $context);

$parameters = $matcher->match('/hello');

Resources

You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/Routing/
$ composer.phar install
$ phpunit