I define a route using the Symfony Routing Component
Using this route i generate an uri. 'https://domain.tl/login'
Upon navigating to that uri, the UrlMatcher fails to match and throws.
// $_SERVER['REQUEST_URI'] == 'https://domain.tl/login'
// old situation
//$request_context = new RequestContext($_SERVER['REQUEST_URI']);
// problem solved:
$protocol = $_SERVER['SERVER_PORT'] == 80 ? 'http':'https';
$request_context = new RequestContext($_SERVER['REQUEST_URI']);
$request_context->setScheme($protocol);
$routes = new RouteCollection;
// should match: https://domain.tl/login
$routes->add('login', new Route('login', array(), array(), array(), '', array('https')));
// reverse routing
$base_uri = new RequestContext;
$base_uri->setHost($_SERVER['HTTP_HOST']);
$generator = new UrlGenerator($routes, $base_uri);
var_dump($generator->generate('login')); // gives: https://domain.tl/login
try
{
$matcher = new UrlMatcher($routes, $request_context);
$matcher->match($_SERVER['REQUEST_URI']); // throws
die('match');
}
catch(\Symfony\Component\Routing\Exception\ResourceNotFoundException $ex)
{
die('no match');
}
I really struggle figuring out how to debug this without diving in the Routing Component code. Hope i am missing something obvious :)
edit: The route does work without the restriction on https. This restriction is needed though.
edit2: it works! i implemented the fix in the code above