@@ -359,7 +359,7 @@ routes with UTF-8 characters:
359359
360360.. configuration-block ::
361361
362- .. code-block :: php-annotations
362+ .. code-block :: php-annotations
363363
364364 // src/AppBundle/Controller/DefaultController.php
365365 namespace AppBundle\Controller;
@@ -379,16 +379,16 @@ routes with UTF-8 characters:
379379 // ...
380380 }
381381
382- .. code-block :: yaml
382+ .. code-block :: yaml
383383
384- # routes .yml
385- route1 :
386- path : /category/{name}
387- defaults : { _controller: 'AppBundle:Default:category' }
388- options :
389- utf8 : true
384+ # app/config/routing .yml
385+ route1 :
386+ path : /category/{name}
387+ defaults : { _controller: 'AppBundle:Default:category' }
388+ options :
389+ utf8 : true
390390
391- .. code-block :: xml
391+ .. code-block :: xml
392392
393393 <!-- app/config/routing.xml -->
394394 <?xml version =" 1.0" encoding =" UTF-8" ?>
@@ -403,26 +403,26 @@ routes with UTF-8 characters:
403403 </route >
404404 </routes >
405405
406- .. code-block :: php
407-
408- // app/config/routing.php
409- use Symfony\Component\Routing\RouteCollection;
410- use Symfony\Component\Routing\Route;
411-
412- $collection = new RouteCollection();
413- $collection->add('route1', new Route('/category/{name}',
414- array(
415- '_controller' => 'AppBundle:Default:category',
416- ),
417- array(),
418- array(
419- 'utf8' => true,
420- )
421- );
406+ .. code-block :: php
407+
408+ // app/config/routing.php
409+ use Symfony\Component\Routing\RouteCollection;
410+ use Symfony\Component\Routing\Route;
411+
412+ $collection = new RouteCollection();
413+ $collection->add('route1', new Route('/category/{name}',
414+ array(
415+ '_controller' => 'AppBundle:Default:category',
416+ ),
417+ array(),
418+ array(
419+ 'utf8' => true,
420+ )
421+ );
422422
423- // ...
423+ // ...
424424
425- return $collection;
425+ return $collection;
426426
427427
428428 In this route, the ``utf8 `` option set to ``true `` makes Symfony consider the
@@ -431,9 +431,11 @@ byte character. This means that so the following URLs would match:
431431``/category/日本語 ``, ``/category/فارسی ``, ``/category/한국어 ``, etc. In case you
432432are wondering, this option also allows to include and match emojis in URLs.
433433
434+ You can also include UTF-8 strings as routing requirements:
435+
434436.. configuration-block ::
435437
436- .. code-block :: php-annotations
438+ .. code-block :: php-annotations
437439
438440 // src/AppBundle/Controller/DefaultController.php
439441 namespace AppBundle\Controller;
@@ -444,32 +446,32 @@ are wondering, this option also allows to include and match emojis in URLs.
444446 class DefaultController extends Controller
445447 {
446448 /**
447- *
448- * @Route(
449- * "/category/{name}",
450- * name="route2",
451- * requirements={"default"="한국어"},
452- * options={"utf8": true}
453- * )
454- *
455- */
449+ *
450+ * @Route(
451+ * "/category/{name}",
452+ * name="route2",
453+ * requirements={"default"="한국어"},
454+ * options={"utf8": true}
455+ * )
456+ *
457+ */
456458 public function defaultAction()
457459 {
458460 // ...
459461 }
460462
461- .. code-block :: yaml
463+ .. code-block :: yaml
462464
463- # routes .yml
464- route2 :
465- path : /default/{default}
466- defaults : { _controller: 'AppBundle:Default:default' }
467- requirements :
468- default : " 한국어"
469- options :
470- utf8 : true
465+ # app/config/routing .yml
466+ route2 :
467+ path : /default/{default}
468+ defaults : { _controller: 'AppBundle:Default:default' }
469+ requirements :
470+ default : " 한국어"
471+ options :
472+ utf8 : true
471473
472- .. code-block :: xml
474+ .. code-block :: xml
473475
474476 <!-- app/config/routing.xml -->
475477 <?xml version =" 1.0" encoding =" UTF-8" ?>
@@ -485,43 +487,43 @@ are wondering, this option also allows to include and match emojis in URLs.
485487 </route >
486488 </routes >
487489
488- .. code-block :: php
489-
490- // app/config/routing.php
491- use Symfony\Component\Routing\RouteCollection;
492- use Symfony\Component\Routing\Route;
493-
494- $collection = new RouteCollection();
495- $collection->add('route2', new Route('/default/{default}',
496- array(
497- '_controller' => 'AppBundle:Default:default',
498- ),
499- array(
500- 'default' => '한국어',
501- ),
502- array(
503- 'utf8' => true,
504- )
505- );
506-
507- // ...
490+ .. code-block :: php
491+
492+ // app/config/routing.php
493+ use Symfony\Component\Routing\RouteCollection;
494+ use Symfony\Component\Routing\Route;
495+
496+ $collection = new RouteCollection();
497+ $collection->add('route2', new Route('/default/{default}',
498+ array(
499+ '_controller' => 'AppBundle:Default:default',
500+ ),
501+ array(
502+ 'default' => '한국어',
503+ ),
504+ array(
505+ 'utf8' => true,
506+ )
507+ );
508508
509- return $collection;
509+ // ...
510510
511+ return $collection;
512+
513+ .. tip ::
511514
512- This second example describes how you can use UTF-8 strings as a routing
513- requirements.
515+ In addition to UTF-8 characters, the Routing component also supports all
516+ the `PCRE Unicode properties `_, which are escape sequences that match
517+ generic character types. For example, ``\p{Lu} `` matches any uppercase
518+ character in any language, ``\p{Greek} `` matches any Greek character,
519+ ``\P{Han} `` matches any character not included in the Chinese Han script.
514520
515521.. note ::
516522
517- In Symfony 3.2 there is no need to set this ``utf8 `` option explicitly.
518- As soon as Symfony finds a UTF-8 character in the route path or requirements,
519- it will turn the UTF-8 support automatically. In addition to UTF-8
520- characters, the Routing component also supports all the `PCRE Unicode properties `_,
521- which are escape sequences that match generic character types. For
522- example, ``\p{Lu} `` matches any uppercase character in any language,
523- ``\p{Greek} `` matches any Greek character, ``\P{Han} `` matches any character
524- not included in the Chinese Han script.
523+ In Symfony 3.2 there is no need to set the ``utf8 `` option explicitly. As
524+ soon as Symfony finds a UTF-8 character in the route path or requirements,
525+ it will turn the UTF-8 support automatically. However, this behaviour is
526+ deprecated and setting the option will be required in Symfony 4.0.
525527
526528Learn more
527529----------
0 commit comments