php8.5
Home/ Manual/ yaf / yaf_controller_abstract/ Yaf_Controller_Abstract::getRequest

Yaf_Controller_Abstract::getRequest

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Retrieve current request object

Description

Yaf_Controller_Abstract::getRequest(): Yaf_Request_Abstract|null

Returns the Yaf_Request_Abstract instance associated with this controller.

Parameters Parameters

Return Values

A Yaf_Request_Abstract instance, or null if no request is available.

Examples

Yaf_Controller_Abstract::getRequest example

php
<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction() {
        $request = $this->getRequest();
        var_dump($request->getModuleName());
        var_dump($request->getControllerName());
        var_dump($request->getActionName());
    }
}
?>

The above example will output something similar to:

output
string(5) "Index"
string(5) "Index"
string(5) "index"

See Also

  • Yaf_Controller_Abstract::getResponse
  • Yaf_Request_Abstract

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