Skip to content

Commit 0fbc883

Browse files
authored
Merge pull request #6957 from kenjis/fix-docs-upgrade_routing.rst
docs: fix upgrade_routing.rst
2 parents 4fd157b + 9f17d79 commit 0fbc883

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

user_guide_src/source/installation/upgrade_routing.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ Upgrade Guide
2222
=============
2323

2424
1. If you use the Auto Routing in the same way as CI3, you need to enable :ref:`auto-routing`.
25-
2. You have to change the syntax of each routing line and append it in **app/Config/Routes.php**. For example:
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:
2627

2728
- ``$route['journals'] = 'blogs';`` to ``$routes->add('journals', 'Blogs::index');``. This would map to the ``index()`` method in the ``Blogs`` controller.
28-
- ``$route['product/(:any)'] = 'catalog/product_lookup';`` to ``$routes->add('product/(:any)', 'Catalog::productLookup');``
29+
- ``$route['product/(:any)'] = 'catalog/product_lookup';`` to ``$routes->add('product/(:segment)', 'Catalog::productLookup');``
2930
- ``$route['login/(.+)'] = 'auth/login/$1';`` to ``$routes->add('login/(.+)', 'Auth::login/$1');``
3031

3132
Code Example

user_guide_src/source/installation/upgrade_routing/001.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
namespace Config;
44

5-
// Create a new instance of our RouteCollection class.
6-
$routes = Services::routes();
5+
// ...
76

8-
// Load the system's routing file first, so that the app and ENVIRONMENT
9-
// can override as needed.
10-
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
11-
require SYSTEMPATH . 'Config/Routes.php';
12-
}
7+
/*
8+
* --------------------------------------------------------------------
9+
* Route Definitions
10+
* --------------------------------------------------------------------
11+
*/
1312

1413
// ...
1514

@@ -21,4 +20,6 @@
2120
$routes->add('posts/update', 'Posts::update');
2221
$routes->add('drivers/create', 'Drivers::create');
2322
$routes->add('drivers/update', 'Drivers::update');
24-
$routes->add('posts/(:any)', 'Posts::view/$1');
23+
$routes->add('posts/(:segment)', 'Posts::view/$1');
24+
25+
// ...
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22
defined('BASEPATH') OR exit('No direct script access allowed');
33

4-
$route['posts/index'] = 'posts/index';
4+
// ...
5+
6+
$route['posts/index'] = 'posts/index';
57
$route['teams/create'] = 'teams/create';
68
$route['teams/update'] = 'teams/update';
79

8-
$route['posts/create'] = 'posts/create';
9-
$route['posts/update'] = 'posts/update';
10+
$route['posts/create'] = 'posts/create';
11+
$route['posts/update'] = 'posts/update';
1012
$route['drivers/create'] = 'drivers/create';
1113
$route['drivers/update'] = 'drivers/update';
12-
$route['posts/(:any)'] = 'posts/view/$1';
14+
$route['posts/(:any)'] = 'posts/view/$1';

0 commit comments

Comments
 (0)