Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Route_Map::__constructYaf_Route_Regex>
^Yaf_Route_MapLast updated: Mon, 26 Oct 2026

Yaf_Route_Map::route

(Yaf >=1.0.0)

Yaf_Route_Map::route — Route a request

Description

public function Yaf_Route_Map::route(Yaf_Request_Abstract $request): bool

Route the request by mapping the whole URI to a controller name or an action name: the path segments of the URI are joined with underscores to form the name.

When the route was constructed with the controller prefer flag on, the result is set as the controller name, otherwise as the action name.

Parameters

request

The Yaf_Request_Abstract instance to route.

Return Values

Always returns true. Note that the map route claims the request even when the URI is empty, in which case no name is set.

Examples

Example #1 Yaf_Route_Map::route() example

<?php
$request = new Yaf_Request_Simple("CLI");
$request->setRequestUri("/product/foo/bar");

$route = new Yaf_Route_Map();
var_dump($route->route($request));
var_dump($request->getActionName());
?>

The above example will output something similar to:

bool(true)
string(15) "product_foo_bar"

Example #2 Yaf_Route_Map::route() example

<?php
$request = new Yaf_Request_Simple("CLI");
$request->setRequestUri("/user/list/_/foo/22");

$route = new Yaf_Route_Map(true, "_");
var_dump($route->route($request));
var_dump($request->getControllerName());
var_dump($request->getParam("foo"));
?>

The above example will output something similar to:

bool(true)
string(9) "User_List"
string(2) "22"

See Also


<Yaf_Route_Map::__constructYaf_Route_Regex>
^Yaf_Route_MapLast updated: Mon, 26 Oct 2026