php8.5
Home/ Manual/ yaf / yaf_dispatcher/ Yaf_Dispatcher::getRequest

Yaf_Dispatcher::getRequest

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Retrieve the request instance

Description

Yaf_Dispatcher::getRequest(): Yaf_Request_Abstract|null

Retrieve the request object held by the dispatcher.

Parameters Parameters

Return Values

The Yaf_Request_Abstract instance, or null if the application is not initialized.

Examples

Yaf_Dispatcher::getRequest example

php
<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $request = Yaf_Dispatcher::getInstance()->getRequest();

        // The dispatcher holds the very same request object that is
        // passed to the controller
        var_dump($request === $this->getRequest());

        return false;
    }
}
?>

The above example will output something similar to:

output
bool(true)

See Also

  • Yaf_Dispatcher::setRequest
  • Yaf_Request_Abstract

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