Skip to content

Commit 404ed93

Browse files
committed
minor #5652 Do not use dynamic REQUEST_URI from $_SERVER as base url (senkal)
This PR was merged into the 2.3 branch. Discussion ---------- Do not use dynamic REQUEST_URI from $_SERVER as base url | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3 | Fixed tickets | I am not sure why we use `$_SERVER['REQUEST_URI']` as a first parameter for `Symfony\Component\Routing\RequestContext` where it expects to get baseUrl. `$_SERVER['REQUEST_URI'] ` is dynamic and shouldn't be used as a static value for baseUrl. Probably better not to pass this parameter at all(default) or use `/`, what I propose. I know that many people won't look that deeply into those examples but, in my opinion, `$_SERVER['REQUEST_URI'] ` is not base url. Not sure what to do with the note about the request uri(the one with http foundation link/info). Maybe the idea was to use `$_SERVER['REQUEST_URI']` in `->match()` examples ? Commits ------- dadefb6 Od not use dynamic REQUEST_URI from $_SERVER as base url
2 parents e037910 + dadefb6 commit 404ed93

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

components/routing/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ your autoloader to load the Routing component::
3939
$routes = new RouteCollection();
4040
$routes->add('route_name', $route);
4141

42-
$context = new RequestContext($_SERVER['REQUEST_URI']);
42+
$context = new RequestContext('/');
4343

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

@@ -207,7 +207,7 @@ a certain route::
207207
$routes = new RouteCollection();
208208
$routes->add('show_post', new Route('/show/{slug}'));
209209

210-
$context = new RequestContext($_SERVER['REQUEST_URI']);
210+
$context = new RequestContext('/');
211211

212212
$generator = new UrlGenerator($routes, $context);
213213

@@ -327,7 +327,7 @@ automatically in the background if you want to use it. A basic example of the
327327
:class:`Symfony\\Component\\Routing\\Router` class would look like::
328328

329329
$locator = new FileLocator(array(__DIR__));
330-
$requestContext = new RequestContext($_SERVER['REQUEST_URI']);
330+
$requestContext = new RequestContext('/');
331331

332332
$router = new Router(
333333
new YamlFileLoader($locator),

0 commit comments

Comments
 (0)