Routing
extends Routing
in package
Routing configuration
Table of Contents
Properties
- $autoRoute : bool
- If TRUE, the system will attempt to match the URI against Controllers by matching each segment against folders/files in APPPATH/Controllers, when a match wasn't found against defined routes.
- $defaultController : string
- For Auto Routing.
- $defaultMethod : string
- For Defined Routes and Auto Routing.
- $defaultNamespace : string
- For Defined Routes and Auto Routing.
- $moduleRoutes : array<string, string>
- For Auto Routing (Improved).
- $multipleSegmentsOneParam : bool
- For Defined Routes.
- $override404 : string|null
- Sets the class/method that should be called if routing doesn't find a match. It can be the controller/method name like: Users::index
- $prioritize : bool
- For Defined Routes.
- $routeFiles : array<int, string>
- For Defined Routes.
- $translateURIDashes : bool
- For Auto Routing.
- $translateUriToCamelCase : bool
- For Auto Routing (Improved).
Properties
$autoRoute
If TRUE, the system will attempt to match the URI against Controllers by matching each segment against folders/files in APPPATH/Controllers, when a match wasn't found against defined routes.
public
bool
$autoRoute
= false
If FALSE, will stop searching and do NO automatic routing.
$defaultController
For Auto Routing.
public
string
$defaultController
= 'Home'
The default controller to use when no other controller has been specified.
Default: 'Home'
$defaultMethod
For Defined Routes and Auto Routing.
public
string
$defaultMethod
= 'index'
The default method to call on the controller when no other method has been set in the route.
Default: 'index'
$defaultNamespace
For Defined Routes and Auto Routing.
public
string
$defaultNamespace
= 'App\Controllers'
The default namespace to use for Controllers when no other namespace has been specified.
Default: 'App\Controllers'
$moduleRoutes
For Auto Routing (Improved).
public
array<string, string>
$moduleRoutes
= []
Map of URI segments and namespaces.
The key is the first URI segment. The value is the controller namespace. E.g., [ 'blog' => 'Acme\Blog\Controllers', ]
$multipleSegmentsOneParam
For Defined Routes.
public
bool
$multipleSegmentsOneParam
= false
If TRUE, matched multiple URI segments will be passed as one parameter.
Default: false
$override404
Sets the class/method that should be called if routing doesn't find a match. It can be the controller/method name like: Users::index
public
string|null
$override404
= null
This setting is passed to the Router class and handled there.
If you want to use a closure, you will have to set it in the routes file by calling:
$routes->set404Override(function() { // Do something here });
Example: public $override404 = 'App\Errors::show404';
$prioritize
For Defined Routes.
public
bool
$prioritize
= false
If TRUE, will enable the use of the 'prioritize' option when defining routes.
Default: false
$routeFiles
For Defined Routes.
public
array<int, string>
$routeFiles
= [APPPATH . 'Config/Routes.php']
An array of files that contain route definitions. Route files are read in order, with the first match found taking precedence.
Default: APPPATH . 'Config/Routes.php'
$translateURIDashes
For Auto Routing.
public
bool
$translateURIDashes
= false
Whether to translate dashes in URIs for controller/method to underscores. Primarily useful when using the auto-routing.
Default: false
$translateUriToCamelCase
For Auto Routing (Improved).
public
bool
$translateUriToCamelCase
= true
Whether to translate dashes in URIs for controller/method to CamelCase. E.g., blog-controller -> BlogController
If you enable this, $translateURIDashes is ignored.
Default: false