8000 The host parameter has to be in defaults, not requirements by MarieMinasyan · Pull Request #3368 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

The host parameter has to be in defaults, not requirements #3368

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 all commits
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
18 changes: 11 additions & 7 deletions components/routing/hostname_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,27 @@ instance, if you want to match both ``m.example.com`` and

return $collection;

.. tip::

Make sure you also include a default option for the ``subdomain``
placeholder, otherwise you need to include the subdomains value each time
you generate the route.

.. sidebar:: Using Service Parameters

You can also use service parameters if you do not want to hardcode the
hostname:

.. tip::

Make sure you also include a default option for the ``subdomain``
placeholder, otherwise you need to include the subdomains value each time
you generate the route.

.. configuration-block::

.. code-block:: yaml

mobile_homepage:
path: /
host: "m.{domain}"
defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage }
defaults:
_controller: AcmeDemoBundle:Main:mobileHomepage
domain: "%domain%"
requirements:
domain: "%domain%"

Expand All @@ -212,6 +214,7 @@ instance, if you want to match both ``m.example.com`` and

<route id="mobile_homepage" path="/" host="m.example.com">
<default key="_controller">AcmeDemoBundle:Main:mobileHomepage</default>
<default key="domain">%domain%</requirement>
<requirement key="domain">%domain%</requirement>
</route>

Expand All @@ -228,6 +231,7 @@ instance, if you want to match both ``m.example.com`` and
$collection = new RouteCollection();
$collection->add('mobile_homepage', new Route('/', array(
'_controller' => 'AcmeDemoBundle:Main:mobileHomepage',
'domain' => '%domain%',
), array(
'domain' => '%domain%',
), array(), 'm.{domain}'));
Expand Down
0