Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fb0c70

Browse files
committed
minor#15042 [Routing] Explain host per locale (t-richard)
This PR was squashed before being merged into the 5.2 branch.Discussion----------[Routing] Explain host per locale<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/releases for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `5.x` for features of unreleased versions).-->Reopens#13571 initially opened by `@odolbeau` but staled for a while then closed when removing master branch.This is just a copy/paste from the inital PR.Documents feature:symfony/symfony#36187Closes#13572Commits-------ebb266c [Routing] Explain host per locale
2 parentsa219258 +ebb266c commit0fb0c70

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎routing.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,53 @@ with a locale. This can be done by defining a different prefix for each locale
22152215
;
22162216
};
22172217
2218+
Another common requirement is to host the website on a different domain
2219+
according to the locale. This can be done by defining a different host for each
2220+
locale.
2221+
2222+
..versionadded::5.1
2223+
2224+
The ability to define an array of hosts was introduced in Symfony 5.1.
2225+
2226+
..configuration-block::
2227+
2228+
..code-block::yaml
2229+
2230+
# config/routes/annotations.yaml
2231+
controllers:
2232+
resource:'../../src/Controller/'
2233+
type:annotation
2234+
host:
2235+
en:'https://www.symfony.com'
2236+
nl:'https://www.symfony.nl'
2237+
2238+
..code-block::xml
2239+
2240+
<!-- config/routes/annotations.xml-->
2241+
<?xml version="1.0" encoding="UTF-8" ?>
2242+
<routesxmlns="http://symfony.com/schema/routing"
2243+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2244+
xsi:schemaLocation="http://symfony.com/schema/routing
2245+
https://symfony.com/schema/routing/routing-1.0.xsd">
2246+
<importresource="../../src/Controller/"type="annotation">
2247+
<hostlocale="en">https://www.symfony.com</host>
2248+
<hostlocale="nl">https://www.symfony.nl</host>
2249+
</import>
2250+
</routes>
2251+
2252+
..code-block::php
2253+
2254+
// config/routes/annotations.php
2255+
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
2256+
return function (RoutingConfigurator $routes) {
2257+
$routes->import('../../src/Controller/', 'annotation')
2258+
->host([
2259+
'en' => 'https://www.symfony.com',
2260+
'nl' => 'https://www.symfony.nl'
2261+
])
2262+
;
2263+
};
2264+
22182265
.. _stateless-routing:
22192266

22202267
Stateless Routes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp