Skip to content

Update routing.rst #7712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ Normally you can pass the values from the ``$_SERVER`` variable to populate the
:class:`Symfony\\Component\\Routing\\RequestContext` in a shortcut::

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RequestContext;

$context = new RequestContext();
$context->fromRequest(Request::createFromGlobals());
Expand All @@ -206,6 +207,9 @@ to find a route that fits the given request you can also build a URL from
a certain route::

use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please keep the alpha order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

use Symfony\Component\Routing\Route;

$routes = new RouteCollection();
$routes->add('show_post', new Route('/show/{slug}'));
Expand Down Expand Up @@ -292,6 +296,7 @@ There is also the :class:`Symfony\\Component\\Routing\\Loader\\ClosureLoader`, w
calls a closure and uses the result as a :class:`Symfony\\Component\\Routing\\RouteCollection`::

use Symfony\Component\Routing\Loader\ClosureLoader;
use Symfony\Component\Routing\RouteCollection;

$closure = function () {
return new RouteCollection();
Expand Down