Skip to content

Some route fixes left after #11085 #11089

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

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,14 @@ If you're using the ``YamlFileLoader``, then route definitions look like this:

# routes.yaml
route1:
path: /foo
defaults: { _controller: 'MyController::fooAction' }
path: /foo
controller: MyController::fooAction
methods: GET|HEAD

route2:
path: /foo/bar
defaults: { _controller: 'MyController::foobarAction' }
path: /foo/bar
controller: FooBarInvokableController
methods: PUT

To load this file, you can use the following code. This assumes that your
``routes.yaml`` file is in the same directory as the below code::
Expand Down
13 changes: 8 additions & 5 deletions routing/hostname_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ You can also set the host option on imported routes:

.. code-block:: php-annotations

// src/Controller/MainController.php
namespace Acme\HelloBundle\Controller;
// vendor/acme/acme-hello-bundle/src/Controller/MainController.php
namespace Acme\AcmeHelloBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
Expand Down Expand Up @@ -417,10 +417,13 @@ You can also set the host option on imported routes:
.. code-block:: php

// config/routes.php
$routes = $loader->import("@AcmeHelloBundle/Resources/config/routing.php");
$routes->setHost('hello.example.com');
namespace Symfony\Component\Routing\Loader\Configurator;

return $routes;
return function (RoutingConfigurator $routes) {
$routes->import("@AcmeHelloBundle/Resources/config/routing.php")
->host('hello.example.com')
;
};

The host ``hello.example.com`` will be set on each route loaded from the new
routing resource.
Expand Down