PHP 8.5.10 Released!

Yaf_Route_Static::route

(Yaf >=1.0.0)

Yaf_Route_Static::routeRoute a request

Description

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

Route the request according to the PATH_INFO style URI: the first path segment is treated as the module name only if it is one of the registered modules, otherwise the segments are mapped to the controller and the action in order. The remaining segments become request parameters.

For example, with no module named foo, /foo/bar/age/10 routes to the controller Foo, the action bar, with a parameter age of 10.

Parameters

request

The Yaf_Request_Abstract instance to route.

Return Values

Always returns true.

Examples

Example #1 Yaf_Route_Static::route() example

<?php
$request = new Yaf_Request_Http("/product/detail/id/10");

/* the static route is the default route of Yaf_Router,
 * registered under the name "_default" */
$route = Yaf_Dispatcher::getInstance()->getRouter()->getRoute("_default");
var_dump($route->route($request));

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

The above example will output something similar to:

bool(true)
string(7) "product"
string(6) "detail"
string(2) "10"

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top