Skip to content

[Routing] Mention that param converters are now native #17999

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

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,11 @@ A common routing need is to convert the value stored in some parameter (e.g. an
integer acting as the user ID) into another value (e.g. the object that
represents the user). This feature is called a "param converter".

To add support for "param converters" we need SensioFrameworkExtraBundle:

.. code-block:: terminal
.. versionadded:: 6.2

$ composer require sensio/framework-extra-bundle
Starting from Symfony 6.2, route param conversion is a built-in feature.
In previous Symfony versions you had to install the package
``sensio/framework-extra-bundle`` before using this feature.

Now, keep the previous route configuration, but change the arguments of the
controller action. Instead of ``string $slug``, add ``BlogPost $post``::
Expand Down Expand Up @@ -984,8 +984,9 @@ this case), the "param converter" makes a database request to find the object
using the request parameters (``slug`` in this case). If no object is found,
Symfony generates a 404 response automatically.

Read the `full param converter documentation`_ to learn about the converters
provided by Symfony and how to configure them.
Check out the `Doctrine param conversion documentation <doctrine-entity-value-resolver>`_
to learn about the ``#[MapEntity]`` attribute that can be used to customize the
database queries used to fetch the object from the route parameter.

Special Parameters
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -2672,5 +2673,4 @@ Learn more about Routing

.. _`PHP regular expressions`: https://www.php.net/manual/en/book.pcre.php
.. _`PCRE Unicode properties`: https://www.php.net/manual/en/regexp.reference.unicode.php
.. _`full param converter documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html
.. _`FOSJsRoutingBundle`: https://github.com/FriendsOfSymfony/FOSJsRoutingBundle