Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created June 2, 2012 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2856566 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2856566 to your computer and use it in GitHub Desktop.
Our new front controller using HTTP Foundation - http://www.symfonycentral.com
<?php
// ...
$request = Request::createFromGlobals();
$routes->add('leap_year', new Routing\Route('/is_leap_year/{year}', array(
'year' => null,
'_controller' => 'LeapYearController::indexAction',
)));
$context = new Routing\RequestContext();
$context->fromRequest($request);
$matcher = new Routing\Matcher\UrlMatcher($routes, $context);
$resolver = new HttpKernel\Controller\ControllerResolver();
try {
$request->attributes->add($matcher->match($request->getPathInfo()));
$controller = $resolver->getController($request);
$arguments = $resolver->getArguments($request, $controller);
$response = call_user_func_array($controller, $arguments);
} // ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment