- ⌂ router
- Methods
- Static Methods
io_comand_mvc\router
Route web requests based on convention and/or routing rules.
The webCOMAND server is responsible for accepting all web requests, and has it's own router to determine which webCOMAND App, package or publication should service the request based on the request URL.
Once webCOMAND has delegated the request to a package, the cMVC Framework router can further delegate the request to controllers or other code. webCOMAND defines the global $_COMAND['REQUEST_URI'], which includes the portion of the URL that comes after the initial portion it used to route the request to the package. This makes it easier for the package to inspect the remaining portion of the URL that it should be concerned with.
The full request URL is accessible from $_SERVER['REQUEST_URI'].
Simple Router Example
If the standard MVC Framework conventions are followed, no customization is required.
// File: packages/com_example_www/index.php
\io_comand_mvc\router::route();
Custom Router Example
Router defaults can be overridden to customize the routing process.
// File: packages/com_example_www/index.php
\io_comand_mvc\router::route([
'namespace'=>__NAMESPACE__,
'namespace_path'=>'/path/to/files/',
'base_url'=>'/some/path/',
'controllers'=>'controllers/',
'views'=>'views/',
'request'=>$_COMAND['REQUEST_URI'],
'default'=>'default_controller',
]);