Skip to content

Commit 7e6fee7

Browse files
committed
docs: improve explanations and add notes
1 parent b7c5db8 commit 7e6fee7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

user_guide_src/source/installation/upgrade_routing.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@ What has been changed
1717
- In CI4 the Auto Routing is disabled by default.
1818
- In CI4 the new more secure :ref:`auto-routing-improved` is introduced.
1919
- In CI4 the routing is no longer configured by setting the routes as array.
20+
- The Wildcard ``(:any)`` In CI3 will be the Placeholder ``(:segment)`` in CI4. The ``(:any)`` in CI4 matches multiple segements. See :ref:`URI Routing <routing-placeholder-any>`.
2021

2122
Upgrade Guide
2223
=============
2324

2425
1. If you use the Auto Routing in the same way as CI3, you need to enable :ref:`auto-routing-legacy`.
25-
2. The placeholder ``(:any)`` in CI3 will be ``(:segment)`` in CI4.
26-
3. You have to change the syntax of each routing line and append it in **app/Config/Routes.php**. For example:
26+
2. You have to change the syntax of each routing line and append it in **app/Config/Routes.php**. For example:
2727

2828
- ``$route['journals'] = 'blogs';`` to ``$routes->add('journals', 'Blogs::index');``. This would map to the ``index()`` method in the ``Blogs`` controller.
29-
- ``$route['product/(:any)'] = 'catalog/product_lookup';`` to ``$routes->add('product/(:segment)', 'Catalog::productLookup');``
29+
- ``$route['product/(:any)'] = 'catalog/product_lookup';`` to ``$routes->add('product/(:segment)', 'Catalog::productLookup');``. Don't forget to replace ``(:any)`` with ``(:segment)``.
3030
- ``$route['login/(.+)'] = 'auth/login/$1';`` to ``$routes->add('login/(.+)', 'Auth::login/$1');``
3131

32+
.. note:: For backward compatibility, ``$routes->add()`` is used here. But we
33+
strongly recommend to use :ref:`routing-http-verb-routes` like
34+
``$routes->get()`` instead of ``$routes->add()`` for security.
35+
3236
Code Example
3337
============
3438

@@ -43,3 +47,7 @@ CodeIgniter Version 4.x
4347
Path: **app/Config/Routes.php**:
4448

4549
.. literalinclude:: upgrade_routing/001.php
50+
51+
.. note:: For backward compatibility, ``$routes->add()`` is used here. But we
52+
strongly recommend to use :ref:`routing-http-verb-routes` like
53+
``$routes->get()`` instead of ``$routes->add()`` for security.

0 commit comments

Comments
 (0)