Skip to content
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

Document new utf8 option of Routing component #6938

Merged
merged 1 commit into from
Oct 6, 2016

Conversation

mickaelandrieu
Copy link
Contributor

Hi,

all credits to @javiereguiluz and @nicolas-grekas, I've just copy/pasted the blog article http://symfony.com/blog/new-in-symfony-3-2-unicode-routing-support#comment-form

Mickaël

@nicolas-grekas
Copy link
Member

See #6890
we now have to decide which one is better :)

@nicolas-grekas
Copy link
Member

or merge both since they aren't on the same page

@mickaelandrieu
Copy link
Contributor Author

mickaelandrieu commented Sep 1, 2016

@nicolas-grekas my bad, didnt thank you have started something... as you like, I wont be sad if you close this one, my only interest is to see this feature documented ^^

By the way, big thanks! From a business/e-commerce point of view, this feature is so useful :)

@@ -346,6 +346,44 @@ automatically in the background if you want to use it. A basic example of the
are saved in the ``cache_dir``. This means your script must have write
permissions for that location.

Unicode routing support
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unicode Routing Support

Unicode routing support
~~~~~~~~~~~~~~~~~~~~~~~

The routing component supports UTF-8 characters in route paths and requirements. Thanks to the `utf8` route option, you can make Symfony match and generate routes with UTF-8 characters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Routing component

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option needs to be enclosed by double backticks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also wrap lines after the first word that crosses the 72nd character.

requirements:
name: ".+"
options:
utf8: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Annotations, XML, and PHP examples too.

options:
utf8: true

In this route, the `utf8` option set to true makes Symfony consider the `.` requirement to match any UTF-8 characters instead of just a single byte character, so the following URLs would match: `/category/日本語`, `/category/فارسی`, `/category/한국어`, etc. In case you are wondering, this option also allows to include and match emojis in URLs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use double backticks everywhere here too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and please wrap lines after the first word that crosses the 72nd character

requirements:
default: "日本語|فارسی"
options:
utf8: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need other format examples here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need ? I don't see the gain here when it's already well described here

I will do it if you insist, though (sounds like a simple copy/paste of the resource I've linked ^ ).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how the doc is yes, config are always in all formats, repeating is teaching isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, let's go for it :)

options:
utf8: true

This second example describes how you can use utf8 string as a routing requirement.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTF-8


.. note::

In Symfony 3.2 there is no need to set this utf8 explicitly. As soon as Symfony finds a UTF-8 character in the route path or requirements, it will turn the UTF-8 support automatically. In addition to UTF-8 characters, the Routing component also supports all the `PCRE Unicode properties`_, which are escape sequences that match generic character types. For example, `\p{Lu}` matches any uppercase character in any language, `\p{Greek}` matches any Greek character, `\P{Han}` matches any character not included in the Chinese Han script.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

In Symfony 3.2 there is no need to set this utf8 explicitly. As soon as Symfony finds a UTF-8 character in the route path or requirements, it will turn the UTF-8 support automatically. In addition to UTF-8 characters, the Routing component also supports all the `PCRE Unicode properties`_, which are escape sequences that match generic character types. For example, `\p{Lu}` matches any uppercase character in any language, `\p{Greek}` matches any Greek character, `\P{Han}` matches any character not included in the Chinese Han script.

.. versionadded:: 3.2
The UTF8 support in route paths and requirements were added in Symfony 3.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTF-8 support for route paths and requirements were introduced in Symfony 3.2.

@mickaelandrieu
Copy link
Contributor Author

Wow ... I feel so bad :( thank you for this review, I will address comments tomorrow!

@xabbuh
Copy link
Member

xabbuh commented Sep 21, 2016

No need to worry. There's not much to change. :)

@mickaelandrieu
Copy link
Contributor Author

Hi @xabbuh,

I've adressed almost all comments except the one about complete all formats, let me know if this need more work :)

Mickaël

@xabbuh
Copy link
Member

xabbuh commented Sep 22, 2016

👍 (except for the missing config formats)


<route id="route1" path="/category/{name}">
<default key="_controller">AppBundle:Default:category</default>
<option key="utf8">true</option>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question here: how can we do to ensure true will be converted to boolean value ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the responsibility of the loader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ... is it good, or does it need much work from me ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good as it is. :)

@@ -346,6 +346,181 @@ automatically in the background if you want to use it. A basic example of the
are saved in the ``cache_dir``. This means your script must have write
permissions for that location.

Unicode Routing support
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support

path: /category/{name}
defaults: { _controller: 'DefaultController::categoryAction' }
options:
utf8: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please indent this line with four spaces

# routes.yml
route1:
path: /category/{name}
defaults: { _controller: 'DefaultController::categoryAction' }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppBundle:Default:category

return $collection;


In this route, the ``utf8`` option set to true makes Symfony consider the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please enclose true in double backticks


In this route, the ``utf8`` option set to true makes Symfony consider the
``.`` requirement to match any UTF-8 characters instead of just a single
byte character, so the following URLs would match: ``/category/日本語``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe split this here: "[...] character. This means that the following URL would match [...]"


.. configuration-block::

.. code-block:: php-annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please indent with four spaces

return $collection;


This second example describes how you can use UTF-8 string as a routing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] as routing requirements.


.. note::

In Symfony 3.2 there is no need to set this utf8 explicitly. As soon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] to explicitly set the utf8 option.


.. versionadded:: 3.2
UTF-8 support for route paths and requirements were introduced in
Symfony 3.2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this up to the beginning of this section.

@mickaelandrieu mickaelandrieu force-pushed the patch-4 branch 2 times, most recently from bbd2931 to 19a864f Compare September 27, 2016 21:07
@mickaelandrieu
Copy link
Contributor Author

@xabbuh thanks again for your time. Comments addressed ;)

~~~~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 3.2
UTF-8 support for route paths and requirements were introduced in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was

path: /category/{name}
defaults: { _controller: 'AppBundle:Default:category' }
options:
utf8: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's the same in the other YAML example too.

@xabbuh
Copy link
Member

xabbuh commented Sep 28, 2016

@mickaelandrieu I left two last minor comments and indentation of the PHP code examples looks weird too. But overall this change looks ready to be merged. 👍

@mickaelandrieu
Copy link
Contributor Author

mickaelandrieu commented Sep 28, 2016

@xabbuh I won't give up now :D let me improve again my contribution ;)

edit: comments addressed (and PHP code cs fixed)

@xabbuh
Copy link
Member

xabbuh commented Sep 28, 2016

👍

Status: Reviewed

@wouterj wouterj merged commit 2569aca into symfony:master Oct 6, 2016
wouterj added a commit that referenced this pull request Oct 6, 2016
…ndrieu)

This PR was merged into the master branch.

Discussion
----------

Document new utf8 option of Routing component

Hi,

all credits to @javiereguiluz and @nicolas-grekas, I've just copy/pasted the blog article http://symfony.com/blog/new-in-symfony-3-2-unicode-routing-support#comment-form

Mickaël

Commits
-------

2569aca Document new utf8 option of Routing component
@wouterj
Copy link
Member

wouterj commented Oct 6, 2016

Thanks @mickaelandrieu! After your quick responses to the reviews, this PR has now made it to the docs!

Fyi, I've fixed some indentation issues and splitted the big note directive in c5328d7.

@mickaelandrieu
Copy link
Contributor Author

@wouterj thank you, it's better now :)
Always happy to help ;)

@mickaelandrieu mickaelandrieu deleted the patch-4 branch October 6, 2016 23:31
xabbuh added a commit to xabbuh/symfony-docs that referenced this pull request Oct 7, 2016
wouterj added a commit that referenced this pull request Oct 20, 2016
This PR was merged into the master branch.

Discussion
----------

[#6938] tweak the wording a bit

Commits
-------

9348ccf [#6938] tweak the wording a bit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants