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_Rewrite::__constructYaf_Router>
^Yaf_Route_RewriteLast updated: Mon, 26 Oct 2026

Yaf_Route_Rewrite::route

(Yaf >=1.0.0)

Yaf_Route_Rewrite::route — Route a request

Description

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

Route the request by matching the URI against the match pattern given to the constructor. When it matches, the module, controller and action are taken from the route array, where a value starting with a colon is resolved from the matched variables.

Parameters

request

The Yaf_Request_Abstract instance to route.

Return Values

Returns true if the URI matches, false otherwise, which makes the router try the next route.

Examples

Example #1 Yaf_Route_Rewrite::route() example

<?php
/* assume the request URI is "/product/php-book" */
$request = new Yaf_Request_Http("/product/php-book");

$route = new Yaf_Route_Rewrite(
    "/product/:name",             // match a URI leading "/product"
    array(
        'controller' => "product", // route to the product controller
    ),
    array()                        // no default values
);

var_dump($route->route($request));

var_dump($request->getControllerName());
var_dump($request->getParam("name"));
?>

The above example will output something similar to:

bool(true)
string(7) "product"
string(8) "php-book"

See Also


<Yaf_Route_Rewrite::__constructYaf_Router>
^Yaf_Route_RewriteLast updated: Mon, 26 Oct 2026