Skip to content

Commit 86d0f3d

Browse files
authored
Merge pull request #6613 from kenjis/fix-docs-routing.rst
docs: add Warning to `$routes->map()`
2 parents ed0cdd0 + 67f48dc commit 86d0f3d

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

user_guide_src/source/incoming/routing.rst

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,6 @@ a simple view:
210210

211211
.. literalinclude:: routing/020.php
212212

213-
Mapping Multiple Routes
214-
=======================
215-
216-
While the ``add()`` method is simple to use, it is often handier to work with multiple routes at once, using
217-
the ``map()`` method. Instead of calling the ``add()`` method for each route that you need to add, you can
218-
define an array of routes and then pass it as the first parameter to the ``map()`` method:
219-
220-
.. literalinclude:: routing/021.php
221-
222213
.. _redirecting-routes:
223214

224215
Redirecting Routes
@@ -319,20 +310,32 @@ This has the added benefit of making the views more readable, too.
319310
Routes with any HTTP verbs
320311
==========================
321312

322-
It is possible to define a route with any HTTP verbs.
323-
You can use the ``add()`` method:
324-
325-
.. literalinclude:: routing/031.php
326-
327313
.. warning:: While the ``add()`` method seems to be convenient, it is recommended to always use the HTTP-verb-based
328314
routes, described above, as it is more secure. If you use the :doc:`CSRF protection </libraries/security>`, it does not protect **GET**
329315
requests. If the URI specified in the ``add()`` method is accessible by the GET method, the CSRF protection
330316
will not work.
331317

318+
It is possible to define a route with any HTTP verbs.
319+
You can use the ``add()`` method:
320+
321+
.. literalinclude:: routing/031.php
322+
332323
.. note:: Using the HTTP-verb-based routes will also provide a slight performance increase, since
333324
only routes that match the current request method are stored, resulting in fewer routes to scan through
334325
when trying to find a match.
335326

327+
Mapping Multiple Routes
328+
=======================
329+
330+
.. warning:: The ``map()`` method is not recommended as well as ``add()``
331+
because it calls ``add()`` internally.
332+
333+
While the ``add()`` method is simple to use, it is often handier to work with multiple routes at once, using
334+
the ``map()`` method. Instead of calling the ``add()`` method for each route that you need to add, you can
335+
define an array of routes and then pass it as the first parameter to the ``map()`` method:
336+
337+
.. literalinclude:: routing/021.php
338+
336339
.. _command-line-only-routes:
337340

338341
Command-Line Only Routes

0 commit comments

Comments
 (0)