Code:
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -37,6 +37,15 @@ $routes->set404Override();
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');
+$routes->group('', ['namespace' => '\App\Controllers\Backend'], static function ($routes) {
+ $routes->get('backend/dashboard', 'Dashboard::index', [
+ 'as' => 'dashboard.index'
+ ]);
+});
+$routes->group('', ['namespace' => '\App\Controllers\Frontend'], static function ($routes) {
+ $routes->get('/{locale}/([a-zA-Z0-9_-]+)/', 'Router::show/$1');
+});
+
/*
* --------------------------------------------------------------------
* Additional Routing
Code:
$ php spark routes
CodeIgniter v4.2.6 Command Line Tool - Server Time: 2022-09-08 16:36:45 UTC-05:00
+--------+---------------------------+-------------------------------------------+----------------+---------------+
| Method | Route | Handler | Before Filters | After Filters |
+--------+---------------------------+-------------------------------------------+----------------+---------------+
| GET | / | \App\Controllers\Home::index | | toolbar |
| GET | backend/dashboard | \App\Controllers\Backend\Dashboard::index | | toolbar |
| GET | {locale}/([a-zA-Z0-9_-]+) | \App\Controllers\Frontend\Router::show/$1 | <unknown> | <unknown> |
| CLI | ci(.*) | \CodeIgniter\CLI\CommandRunner::index/$1 | | |
+--------+---------------------------+-------------------------------------------+----------------+---------------+
Or
Code:
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -26,6 +26,7 @@ $routes->set404Override();
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
// $routes->setAutoRoute(false);
+$routes->setPrioritize();
/*
* --------------------------------------------------------------------
@@ -37,6 +38,15 @@ $routes->set404Override();
// route since we don't have to scan directories.
$routes->get('/', 'Home::index');
+$routes->group('', ['namespace' => '\App\Controllers\Frontend', 'priority' => 1], static function ($routes) {
+ $routes->get('/{locale}/([a-zA-Z0-9_-]+)/', 'Router::show/$1');
+});
+$routes->group('', ['namespace' => '\App\Controllers\Backend'], static function ($routes) {
+ $routes->get('backend/dashboard', 'Dashboard::index', [
+ 'as' => 'dashboard.index',
+ ]);
+});
+
/*
* --------------------------------------------------------------------
* Additional Routing