php8.5
Home/ Manual/ yaf / yaf_route_simple/ Yaf_Route_Simple::route

Yaf_Route_Simple::route

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Route a request

Description

Yaf_Route_Simple::route(Yaf_Request_Abstract $request): bool

Route the request with query parameters: the module, controller and action names are retrieved from the query variables named as the ones given to the constructor.

Parameters

request

The Yaf_Request_Abstract instance to route.

Return Values

Returns true if any of the three query variables is present, false otherwise, which makes the router try the next route.

Examples

Yaf_Route_Simple::route example

php
<?php
/* assume the request was made with
 * http://yourdomain.com/index.php?m=main&c=product&a=detail */
$request = new Yaf_Request_Http("/index.php");

$route = new Yaf_Route_Simple("m", "c", "a");
var_dump($route->route($request));

var_dump($request->getModuleName());
var_dump($request->getControllerName());
var_dump($request->getActionName());
?>

The above example will output something similar to:

output
bool(true)
string(4) "main"
string(7) "product"
string(6) "detail"

See Also

  • Yaf_Route_Simple::__construct
  • Yaf_Route_Simple::assemble

Source: reference/yaf/yaf_route_simple/route.xml · from the official PHP manual (php/doc-en)