Request Routing
Routing in Festi is typically handled by a system plugin. The Jimbo system plugin is commonly used for this purpose.
Routing via the Jimbo Plugin
All plugins involved in routing must be registered in the festi_plugins
table.
If Jimbo is used as the system plugin, routing is managed through the following tables:
festi_url_areas
– Defines Routing Areas in the system, such as default, backend, etc.festi_url_rules
– Stores regular expressions that define routes and specify which plugin and method should handle matching requests.festi_url_rules2areas
– Links routing rules to specific system zones.
Routing Areas (festi_url_areas
)
Routing Areas act as abstractions that allow the system to handle different use cases. For example, if both the admin panel and the website have the same URL (/login/
), routing must direct requests to the appropriate handlers. By default, Jimbo assigns the default
area.
Routing Setup Cycle:
- Add a routing rule to
festi_url_rules
. - Link the rule to an area in festi_url_rules2areas.
Routing via $GLOBALS
Routing rules can also be defined using the $GLOBALS['urlRules']
array. The key should be a regular expression that matches the desired URL, and the value should be an array containing the plugin name and method:
$GLOBALS['urlRules'] = array(
'~^/my/test/([0-9]+)/$~' => array('My', 'onDisplayDefault')
);
Routing via the Web Interface
You can manage routing rules via the DGS interface available at: /festi/festi_url_rules/Jimbo/
Regular Expressions in Routing
If regular expressions include capture groups, the extracted values will be passed as parameters to the plugin method. For example, given the pattern:
~^/my/([a-z]+)/([0-9]+)/$~
Calling the URL:
/my/go/123/
Will invoke the plugin method with the extracted parameters:
class MyPlugin extends DisplayPlugin
{
public function onDisplayDefault(Response &$response, $type, $id)
{
// $type = 'go'
// $id = 123
}
}