File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -794,6 +794,54 @@ parameter:
794794 To give a ``null `` default value to any parameter, add nothing after the
795795 ``? `` character (e.g. ``/blog/{page?} ``).
796796
797+ Priority Parameter
798+ ~~~~~~~~~~~~~~~~~~
799+
800+ .. versionadded :: 5.1
801+
802+ The ``priority `` parameter was introduced in Symfony 5.1
803+
804+ When defining a greedy pattern that matches many routes, this may be at the
805+ beginning of your routing collection and prevents any route defined after to be
806+ matched.
807+ A ``priority `` optional parameter is available in order to let you choose the
808+ order of your routes, and it is only available when using annotations.
809+
810+ .. code-block :: php-annotations
811+
812+ // src/Controller/BlogController.php
813+ namespace App\Controller;
814+
815+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
816+ use Symfony\Component\Routing\Annotation\Route;
817+
818+ class BlogController extends AbstractController
819+ {
820+ /**
821+ * This route has a greedy pattern and is defined first.
822+ *
823+ * @Route("/blog/{slug}", name="blog_show")
824+ */
825+ public function show(string $slug)
826+ {
827+ // ...
828+ }
829+
830+ /**
831+ * This route could not be matched without defining a higher priority than 0.
832+ *
833+ * @Route("/blog/list", name="blog_list", priority=2)
834+ */
835+ public function list()
836+ {
837+ // ...
838+ }
839+ }
840+
841+ The priority parameter expects an integer value. Routes with higher priority
842+ are sorted before routes with lower priority. The default value when it is not
843+ defined is ``0 ``.
844+
797845Parameter Conversion
798846~~~~~~~~~~~~~~~~~~~~
799847
You can’t perform that action at this time.
0 commit comments