@@ -399,7 +399,7 @@ routes with UTF-8 characters:
399
399
class DefaultController extends AbstractController
400
400
{
401
401
/**
402
- * @Route("/category/{name}", name="route1", options={" utf8": true} )
402
+ * @Route("/category/{name}", name="route1", utf8= true)
403
403
*/
404
404
public function category()
405
405
{
@@ -411,8 +411,7 @@ routes with UTF-8 characters:
411
411
route1 :
412
412
path : /category/{name}
413
413
controller : App\Controller\DefaultController::category
414
- options :
415
- utf8 : true
414
+ utf8 : true
416
415
417
416
.. code-block :: xml
418
417
@@ -422,9 +421,10 @@ routes with UTF-8 characters:
422
421
xsi : schemaLocation =" http://symfony.com/schema/routing
423
422
http://symfony.com/schema/routing/routing-1.0.xsd" >
424
423
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" />
428
428
</routes >
429
429
430
430
.. code-block :: php
@@ -437,12 +437,61 @@ routes with UTF-8 characters:
437
437
return function (RoutingConfigurator $routes) {
438
438
$routes->add('route1', '/category/{name}')
439
439
->controller([DefaultController::class, 'category'])
440
- ->options([
441
- 'utf8' => true,
442
- ])
440
+ ->utf8()
443
441
;
444
442
};
445
443
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
+
446
495
In this route, the ``utf8 `` option set to ``true `` makes Symfony consider the
447
496
``. `` requirement to match any UTF-8 characters instead of just a single
448
497
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:
467
516
* "/category/{name}",
468
517
* name="route2",
469
518
* defaults={"name"="한국어"},
470
- * options={" utf8": true}
519
+ * utf8= true
471
520
* )
472
521
*/
473
522
public function category()
@@ -482,8 +531,7 @@ You can also include UTF-8 strings as routing requirements:
482
531
controller : ' App\Controller\DefaultController::category'
483
532
defaults :
484
533
name : " 한국어"
485
- options :
486
- utf8 : true
534
+ utf8 : true
487
535
488
536
.. code-block :: xml
489
537
@@ -493,9 +541,11 @@ You can also include UTF-8 strings as routing requirements:
493
541
xsi : schemaLocation =" http://symfony.com/schema/routing
494
542
http://symfony.com/schema/routing/routing-1.0.xsd" >
495
543
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" >
497
548
<default key =" name" >한국어</default >
498
- <option key =" utf8" >true</option >
499
549
</route >
500
550
</routes >
501
551
@@ -512,9 +562,7 @@ You can also include UTF-8 strings as routing requirements:
512
562
->defaults([
513
563
'name' => '한국어',
514
564
])
515
- ->options([
516
- 'utf8' => true,
517
- ])
565
+ ->utf8()
518
566
;
519
567
};
520
568
0 commit comments