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

Appearance settings

Commit 06a71a9

Browse filesBrowse files
author
Jules Pietri
committed
[Routing][DX] Exposed "compiler_class" and "utf8" options
1 parent 0c1aa7d commit 06a71a9
Copy full SHA for 06a71a9

File tree

1 file changed

+65
-17
lines changed
Filter options

1 file changed

+65
-17
lines changed

‎components/routing.rst

Copy file name to clipboardExpand all lines: components/routing.rst
+65-17Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ routes with UTF-8 characters:
399399
class DefaultController extends AbstractController
400400
{
401401
/**
402-
* @Route("/category/{name}", name="route1", options={"utf8": true})
402+
* @Route("/category/{name}", name="route1", utf8=true)
403403
*/
404404
public function category()
405405
{
@@ -411,8 +411,7 @@ routes with UTF-8 characters:
411411
route1:
412412
path: /category/{name}
413413
controller: App\Controller\DefaultController::category
414-
options:
415-
utf8: true
414+
utf8: true
416415
417416
.. code-block:: xml
418417
@@ -422,9 +421,10 @@ routes with UTF-8 characters:
422421
xsi:schemaLocation="http://symfony.com/schema/routing
423422
http://symfony.com/schema/routing/routing-1.0.xsd">
424423
425-
<route id="route1" path="/category/{name}" controller="App\Controller\DefaultController::category">
426-
<option key="utf8">true</option>
427-
</route>
424+
<route id="route1"
425+
path="/category/{name}"
426+
controller="App\Controller\DefaultController::category"
427+
utf8="true" />
428428
</routes>
429429
430430
.. code-block:: php
@@ -437,12 +437,61 @@ routes with UTF-8 characters:
437437
return function (RoutingConfigurator $routes) {
438438
$routes->add('route1', '/category/{name}')
439439
->controller([DefaultController::class, 'category'])
440-
->options([
441-
'utf8' => true,
442-
])
440+
->utf8()
443441
;
444442
};
445443
444+
.. versionadded:: 4.3
445+
446+
The ``utf8`` shortcut has been introduced in Symfony 4.3.
447+
Before you has to use the ``options`` setting to define
448+
this value:
449+
450+
.. configuration-block::
451+
452+
.. code-block:: php-annotations
453+
454+
route1:
455+
path: /category/{name}
456+
controller: App\Controller\DefaultController::category
457+
options: { utf8: true }
458+
459+
.. code-block:: yaml
460+
461+
route1:
462+
path: /category/{name}
463+
controller: App\Controller\DefaultController::category
464+
utf8: true
465+
466+
.. code-block:: xml
467+
468+
<?xml version="1.0" encoding="UTF-8" ?>
469+
<routes xmlns="http://symfony.com/schema/routing"
470+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
471+
xsi:schemaLocation="http://symfony.com/schema/routing
472+
http://symfony.com/schema/routing/routing-1.0.xsd">
473+
474+
<route id="route1"
475+
path="/category/{name}"
476+
controller="App\Controller\DefaultController::category" >
477+
<option key="utf8">true</option>
478+
</route>
479+
</routes>
480+
481+
.. code-block:: php
482+
483+
// config/routes.php
484+
namespace Symfony\Component\Routing\Loader\Configurator;
485+
486+
use App\Controller\DefaultController;
487+
488+
return function (RoutingConfigurator $routes) {
489+
$routes->add('route1', '/category/{name}')
490+
->controller([DefaultController::class, 'category'])
491+
->options(['utf8' => true])
492+
;
493+
};
494+
446495
In this route, the ``utf8`` option set to ``true`` makes Symfony consider the
447496
``.`` requirement to match any UTF-8 characters instead of just a single
448497
byte character. This means that so the following URLs would match:
@@ -467,7 +516,7 @@ You can also include UTF-8 strings as routing requirements:
467516
* "/category/{name}",
468517
* name="route2",
469518
* defaults={"name"="한국어"},
470-
* options={"utf8": true}
519+
* utf8=true
471520
* )
472521
*/
473522
public function category()
@@ -482,8 +531,7 @@ You can also include UTF-8 strings as routing requirements:
482531
controller: 'App\Controller\DefaultController::category'
483532
defaults:
484533
name: "한국어"
485-
options:
486-
utf8: true
534+
utf8: true
487535
488536
.. code-block:: xml
489537
@@ -493,9 +541,11 @@ You can also include UTF-8 strings as routing requirements:
493541
xsi:schemaLocation="http://symfony.com/schema/routing
494542
http://symfony.com/schema/routing/routing-1.0.xsd">
495543
496-
<route id="route2" path="/category/{name}" controller="App\Controller\DefaultController::category">
544+
<route id="route2"
545+
path="/category/{name}"
546+
controller="App\Controller\DefaultController::category"
547+
utf8="true" >
497548
<default key="name">한국어</default>
498-
<option key="utf8">true</option>
499549
</route>
500550
</routes>
501551
@@ -512,9 +562,7 @@ You can also include UTF-8 strings as routing requirements:
512562
->defaults([
513563
'name' => '한국어',
514564
])
515-
->options([
516-
'utf8' => true,
517-
])
565+
->utf8()
518566
;
519567
};
520568

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.