3
declare(strict_types=1);
6
* This file is part of CodeIgniter 4 framework.
8
* (c) CodeIgniter Foundation <admin@codeigniter.com>
10
* For the full copyright and license information, please view
11
* the LICENSE file that was distributed with this source code.
14
namespace CodeIgniter\Config;
17
* Routing configuration
19
class Routing extends BaseConfig
23
* An array of files that contain route definitions.
24
* Route files are read in order, with the first match
25
* found taking precedence.
27
* Default: APPPATH . 'Config/Routes.php'
31
public array $routeFiles = [
32
APPPATH . 'Config/Routes.php',
36
* For Defined Routes and Auto Routing.
37
* The default namespace to use for Controllers when no other
38
* namespace has been specified.
40
* Default: 'App\Controllers'
42
public string $defaultNamespace = 'App\Controllers';
46
* The default controller to use when no other controller has been
51
public string $defaultController = 'Home';
54
* For Defined Routes and Auto Routing.
55
* The default method to call on the controller when no other
56
* method has been set in the route.
60
public string $defaultMethod = 'index';
64
* Whether to translate dashes in URIs for controller/method to underscores.
65
* Primarily useful when using the auto-routing.
69
public bool $translateURIDashes = false;
72
* Sets the class/method that should be called if routing doesn't
73
* find a match. It can be the controller/method name like: Users::index
75
* This setting is passed to the Router class and handled there.
77
* If you want to use a closure, you will have to set it in the
78
* routes file by calling:
80
* $routes->set404Override(function() {
81
* // Do something here
85
* public $override404 = 'App\Errors::show404';
87
public ?string $override404 = null;
90
* If TRUE, the system will attempt to match the URI against
91
* Controllers by matching each segment against folders/files
92
* in APPPATH/Controllers, when a match wasn't found against
95
* If FALSE, will stop searching and do NO automatic routing.
97
public bool $autoRoute = false;
100
* For Defined Routes.
101
* If TRUE, will enable the use of the 'prioritize' option
102
* when defining routes.
106
public bool $prioritize = false;
109
* For Defined Routes.
110
* If TRUE, matched multiple URI segments will be passed as one parameter.
114
public bool $multipleSegmentsOneParam = false;
117
* For Auto Routing (Improved).
118
* Map of URI segments and namespaces.
120
* The key is the first URI segment. The value is the controller namespace.
123
* 'blog' => 'Acme\Blog\Controllers',
126
* @var array<string, string>
128
public array $moduleRoutes = [];
131
* For Auto Routing (Improved).
132
* Whether to translate dashes in URIs for controller/method to CamelCase.
133
* E.g., blog-controller -> BlogController
135
* If you enable this, $translateURIDashes is ignored.
139
public bool $translateUriToCamelCase = false;