Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Dispatcher::registerPluginYaf_Dispatcher::setDefaultAction>
^Yaf_DispatcherLast updated: Mon, 26 Oct 2026

Yaf_Dispatcher::returnResponse

(Yaf >=1.0.0)

Yaf_Dispatcher::returnResponse — Switch on/off returning the response

Description

public function Yaf_Dispatcher::returnResponse(bool $flag = false): Yaf_Dispatcher|bool

Switch whether Yaf_Application::run() returns the response object instead of sending it to the client directly. When enabled, $response = $app->run() gives you the Yaf_Response_Abstract instance so it can be further manipulated. Available since Yaf 3.2.2.

Parameters

flag

Whether to return the response instead of sending it.

Note:

If this parameter is not given, the current state is returned instead.

Return Values

Returns the Yaf_Dispatcher object itself when flag is given, or a bool indicating the current state when it is not.

Examples

Example #1 Yaf_Dispatcher::returnResponse() example

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

Yaf_Dispatcher::getInstance()->returnResponse(true);

// $app->run() now returns the response instead of flushing it
$response = $app->run();

$response->setHeader("X-Generator", "Yaf");
$response->response();
?>

See Also


<Yaf_Dispatcher::registerPluginYaf_Dispatcher::setDefaultAction>
^Yaf_DispatcherLast updated: Mon, 26 Oct 2026