You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/installation/upgrade_routing.rst
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,18 +17,22 @@ What has been changed
17
17
- In CI4 the Auto Routing is disabled by default.
18
18
- In CI4 the new more secure :ref:`auto-routing-improved` is introduced.
19
19
- 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>`.
20
21
21
22
Upgrade Guide
22
23
=============
23
24
24
25
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:
27
27
28
28
- ``$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)``.
30
30
- ``$route['login/(.+)'] = 'auth/login/$1';`` to ``$routes->add('login/(.+)', 'Auth::login/$1');``
31
31
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
+
32
36
Code Example
33
37
============
34
38
@@ -43,3 +47,7 @@ CodeIgniter Version 4.x
43
47
Path: **app/Config/Routes.php**:
44
48
45
49
.. 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