You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
If you want to match all urls which start with a certain path and end in an
arbitrary suffix you can use the following route definition::
$route = new Route('/start/{suffix}', array('suffix' => ''), array('suffix' => '.*'));
Using Prefixes
~~~~~~~~~~~~~~
You can add routes or other instances of
You can add routes or other instances of
:class:`Symfony\\Component\\Routing\\RouteCollection` to *another* collection.
This way you can build a tree of routes. Additionally you can define a prefix,
default requirements and default options to all routes of a subtree::
Expand All
@@ -144,18 +144,18 @@ default requirements and default options to all routes of a subtree::
Set the Request Parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~
The :class:`Symfony\\Component\\Routing\\RequestContext` provides information
The :class:`Symfony\\Component\\Routing\\RequestContext` provides information
about the current request. You can define all parameters of an HTTP request
with this class via its constructor::
public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443)
.. _components-routing-http-foundation:
Normally you can pass the values from the ``$_SERVER`` variable to populate the
Normally you can pass the values from the ``$_SERVER`` variable to populate the
:class:`Symfony\\Component\\Routing\\RequestContext`. But If you use the
:doc:`HttpFoundation<http_foundation>` component, you can use its
:class:`Symfony\\Component\\HttpFoundation\\Request` class to feed the
:doc:`HttpFoundation<http_foundation>` component, you can use its
:class:`Symfony\\Component\\HttpFoundation\\Request` class to feed the
:class:`Symfony\\Component\\Routing\\RequestContext` in a shortcut::
use Symfony\Component\HttpFoundation\Request;
Expand DownExpand Up
@@ -250,7 +250,7 @@ have to provide the name of a php file which returns a :class:`Symfony\\Componen
Routes as Closures
..................
There is also the :class:`Symfony\\Component\\Routing\\Loader\\ClosureLoader`, which
There is also the :class:`Symfony\\Component\\Routing\\Loader\\ClosureLoader`, which
calls a closure and uses the result as a :class:`Symfony\\Component\\Routing\\RouteCollection`::
use Symfony\Component\Routing\Loader\ClosureLoader;
Expand DownExpand Up
@@ -280,9 +280,9 @@ a path to the main route definition and some other settings::
public function __construct(LoaderInterface $loader, $resource, array $options = array(), RequestContext $context = null, array $defaults = array());
With the ``cache_dir`` option you can enable route caching (if you provide a
path) or disable caching (if it's set to ``null``). The caching is done
automatically in the background if you want to use it. A basic example of the
With the ``cache_dir`` option you can enable route caching (if you provide a
path) or disable caching (if it's set to ``null``). The caching is done
automatically in the background if you want to use it. A basic example of the
:class:`Symfony\\Component\\Routing\\Router` class would look like::
$locator = new FileLocator(array(__DIR__));
Expand All
@@ -298,6 +298,15 @@ automatically in the background if you want to use it. A basic example of the
.. note::
If you use caching, the Routing component will compile new classes which
are saved in the ``cache_dir``. This means your script must have write
If you use caching, the Routing component will compile new classes which
are saved in the ``cache_dir``. This means your script must have write
permissions for that location.
.. tip::
As of Symfony 2.1, the Routing component also accepts Unicode values
in routes like this::
$routes->add('unicode_route', new Route('/Жени'));
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.