Skip to content

Commit fb0a5bc

Browse files
committed
docs: use Array Callable Syntax for routing
1 parent 3d00d96 commit fb0a5bc

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

user_guide_src/source/tutorial/create_news_items/004.php

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

33
// ...
44

5-
$routes->match(['get', 'post'], 'news/create', 'News::create');
6-
$routes->get('news/(:segment)', 'News::view/$1');
7-
$routes->get('news', 'News::index');
8-
$routes->get('pages', 'Pages::index');
9-
$routes->get('(:any)', 'Pages::view/$1');
5+
use App\Controllers\News;
6+
use App\Controllers\Pages;
7+
8+
$routes->match(['get', 'post'], 'news/create', [News::class, 'create']);
9+
$routes->get('news/(:segment)', [News::class, 'view']);
10+
$routes->get('news', [News::class, 'index']);
11+
$routes->get('pages', [Pages::class, 'index']);
12+
$routes->get('(:any)', [Pages::class, 'view']);
1013

1114
// ...

user_guide_src/source/tutorial/news_section/008.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
// ...
44

5-
$routes->get('news/(:segment)', 'News::view/$1');
6-
$routes->get('news', 'News::index');
7-
$routes->get('pages', 'Pages::index');
8-
$routes->get('(:any)', 'Pages::view/$1');
5+
use App\Controllers\News;
6+
use App\Controllers\Pages;
7+
8+
$routes->get('news/(:segment)', [News::class, 'view']);
9+
$routes->get('news', [News::class, 'index']);
10+
$routes->get('pages', [Pages::class, 'index']);
11+
$routes->get('(:any)', [Pages::class, 'view']);
912

1013
// ...

user_guide_src/source/tutorial/static_pages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Add the following lines, **after** the route directive for '/'.
147147

148148
CodeIgniter reads its routing rules from top to bottom and routes the
149149
request to the first matching rule. Each rule is a regular expression
150-
(left-side) mapped to a controller and method name separated by slashes
150+
(left-side) mapped to a controller and method name
151151
(right-side). When a request comes in, CodeIgniter looks for the first
152152
match, and calls the appropriate controller and method, possibly with
153153
arguments.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
22

3-
$routes->get('pages', 'Pages::index');
4-
$routes->get('(:any)', 'Pages::view/$1');
3+
use App\Controllers\Pages;
4+
5+
$routes->get('pages', [Pages::class, 'index']);
6+
$routes->get('(:any)', [Pages::class, 'view']);

0 commit comments

Comments
 (0)