Skip to content

Commit bd0bf21

Browse files
committed
docs: add about locale routes
1 parent 112ba2a commit bd0bf21

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

docs/customization/route_config.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Customizing Routes
22

3-
If you need to customize how any of the auth features are handled, you will likely need to update the routes to point to the correct controllers. You can still use the `service('auth')->routes()` helper, but you will need to pass the `except` option with a list of routes to customize:
3+
## Change Some Routes
4+
5+
If you need to customize how any of the auth features are handled, you will likely need to update the routes to point to the correct controllers.
6+
7+
You can still use the `service('auth')->routes()` helper, but you will need to pass the `except` option with a list of routes to customize:
48

59
```php
610
service('auth')->routes($routes, ['except' => ['login', 'register']]);
@@ -12,3 +16,36 @@ Then add the routes to your customized controllers:
1216
$routes->get('login', '\App\Controllers\Auth\LoginController::loginView');
1317
$routes->get('register', '\App\Controllers\Auth\RegisterController::registerView');
1418
```
19+
20+
After customization, check your routes with the [spark routes](https://codeigniter.com/user_guide/incoming/routing.html#spark-routes) command.
21+
22+
## Use Locale Routes
23+
24+
You can use the `{locale}` placeholder in your routes
25+
(see [Locale Detection](https://codeigniter.com/user_guide/outgoing/localization.html#in-routes)).
26+
27+
```php
28+
$routes->group('{locale}', static function($routes) {
29+
service('auth')->routes($routes);
30+
});
31+
```
32+
33+
The above code registers the following routes:
34+
35+
```text
36+
+--------+----------------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+
37+
| Method | Route | Name | Handler | Before Filters | After Filters |
38+
+--------+----------------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+
39+
| GET | {locale}/register | register | \CodeIgniter\Shield\Controllers\RegisterController::registerView | session | toolbar |
40+
| GET | {locale}/login | login | \CodeIgniter\Shield\Controllers\LoginController::loginView | session | toolbar |
41+
| GET | {locale}/login/magic-link | magic-link | \CodeIgniter\Shield\Controllers\MagicLinkController::loginView | session | toolbar |
42+
| GET | {locale}/login/verify-magic-link | verify-magic-link | \CodeIgniter\Shield\Controllers\MagicLinkController::verify | session | toolbar |
43+
| GET | {locale}/logout | logout | \CodeIgniter\Shield\Controllers\LoginController::logoutAction | session | toolbar |
44+
| GET | {locale}/auth/a/show | auth-action-show | \CodeIgniter\Shield\Controllers\ActionController::show | session | toolbar |
45+
| POST | {locale}/register | register | \CodeIgniter\Shield\Controllers\RegisterController::registerAction | session | toolbar |
46+
| POST | {locale}/login | » | \CodeIgniter\Shield\Controllers\LoginController::loginAction | session | toolbar |
47+
| POST | {locale}/login/magic-link | » | \CodeIgniter\Shield\Controllers\MagicLinkController::loginAction | session | toolbar |
48+
| POST | {locale}/auth/a/handle | auth-action-handle | \CodeIgniter\Shield\Controllers\ActionController::handle | session | toolbar |
49+
| POST | {locale}/auth/a/verify | auth-action-verify | \CodeIgniter\Shield\Controllers\ActionController::verify | session | toolbar |
50+
+--------+----------------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+
51+
```

0 commit comments

Comments
 (0)