|
|
12 years ago | |
|---|---|---|
| .. | ||
| Annotation | 12 years ago | |
| Exception | 12 years ago | |
| Generator | 12 years ago | |
| Loader | 12 years ago | |
| Matcher | 12 years ago | |
| Tests | 12 years ago | |
| .gitignore | 12 years ago | |
| CHANGELOG.md | 12 years ago | |
| CompiledRoute.php | 12 years ago | |
| LICENSE | 12 years ago | |
| README.md | 12 years ago | |
| RequestContext.php | 12 years ago | |
| RequestContextAwareInterface.php | 12 years ago | |
| Route.php | 12 years ago | |
| RouteCollection.php | 12 years ago | |
| RouteCompiler.php | 12 years ago | |
| RouteCompilerInterface.php | 12 years ago | |
| Router.php | 12 years ago | |
| RouterInterface.php | 12 years ago | |
| composer.json | 12 years ago | |
| phpunit.xml.dist | 12 years ago | |
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');
You can run the unit tests with the following command:
$ cd path/to/Symfony/Component/Routing/
$ composer.phar install
$ phpunit