Skip to content

Commit f52ab9d

Browse files
committed
patch: change prefix option to group in routes configuration
1 parent ded8c19 commit f52ab9d

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

docs/customization/route_config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ This will generate the routes with the specified namespace instead of the defaul
3131

3232
## Change Prefix
3333

34-
If you wish, you can prefix all defined authentication routes using the `prefix` option. This is particularly useful if you want all your routes to be under the same root (for example, `auth/login`, `auth/register`).
34+
If you wish, you can prefix all defined authentication routes using the `group` option. This is particularly useful if you want all your routes to be under the same root (for example, `auth/login`, `auth/register`).
3535

3636
```php
37-
service('auth')->routes($routes, ['prefix' => 'auth']);
37+
service('auth')->routes($routes, ['group' => 'auth']);
3838
```
3939

4040
This generates routes whose paths are all prefixed with `auth`.

src/Auth.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ public function authenticate(array $credentials): Result
131131
* Usage (in Config/Routes.php):
132132
* - auth()->routes($routes);
133133
* - auth()->routes($routes, ['except' => ['login', 'register']])
134-
* - auth()->routes($routes, ['prefix' => 'auth'])
134+
* - auth()->routes($routes, ['group' => 'auth'])
135135
*/
136136
public function routes(RouteCollection &$routes, array $config = []): void
137137
{
138138
$authRoutes = config('AuthRoutes')->routes;
139139

140140
$namespace = $config['namespace'] ?? 'CodeIgniter\Shield\Controllers';
141-
$prefix = $config['prefix'] ?? '/';
141+
$group = $config['group'] ?? '/';
142142

143-
$routes->group($prefix, ['namespace' => $namespace], static function (RouteCollection $routes) use ($authRoutes, $config): void {
143+
$routes->group($group, ['namespace' => $namespace], static function (RouteCollection $routes) use ($authRoutes, $config): void {
144144
foreach ($authRoutes as $name => $row) {
145145
if (! isset($config['except']) || ! in_array($name, $config['except'], true)) {
146146
foreach ($row as $params) {

tests/Unit/AuthRoutesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testRoutesCustomPrefix(): void
8686
$collection = single_service('routes');
8787
$auth = service('auth');
8888

89-
$auth->routes($collection, ['prefix' => 'auth']);
89+
$auth->routes($collection, ['group' => 'auth']);
9090

9191
if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) {
9292
$routes = $collection->getRoutes('GET');

0 commit comments

Comments
 (0)