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

Yaf_Dispatcher::setRequest

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Set the request object

Description

Yaf_Dispatcher::setRequest(Yaf_Request_Abstract $request): Yaf_Dispatcher|null

Set the request object used by the dispatcher. This allows using a custom request implementation instead of the built-in Yaf_Request_Http or Yaf_Request_Simple.

Parameters

request

A Yaf_Request_Abstract instance.

Return Values

Returns the Yaf_Dispatcher object itself on success, or null if the application is not initialized.

Examples

Yaf_Dispatcher::setRequest example

php
<?php
$app = new Yaf_Application(dirname(__FILE__) . "/conf/application.ini");

// Run the application from a cron job:
// $ php cron.php index/index/cleanup
$request = new Yaf_Request_Simple("CLI");

Yaf_Dispatcher::getInstance()->setRequest($request);

$app->run();
?>

See Also

  • Yaf_Dispatcher::getRequest
  • Yaf_Request_Abstract

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