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_Controller_Abstract::getRequestYaf_Controller_Abstract::getView>
^Yaf_Controller_AbstractLast updated: Mon, 26 Oct 2026

Yaf_Controller_Abstract::getResponse

(Yaf >=1.0.0)

Yaf_Controller_Abstract::getResponse — Retrieve current response object

Description

public function Yaf_Controller_Abstract::getResponse(): ?Yaf_Response_Abstract

Returns the Yaf_Response_Abstract instance associated with this controller.

Parameters

This function has no parameters.

Return Values

A Yaf_Response_Abstract instance, or null if no response is available.

Examples

Example #1 Yaf_Controller_Abstract::getResponse() example

<?php
class ProductController extends Yaf_Controller_Abstract
{
    public function apiAction() {
        // build the answer ourselves, no template needed
        Yaf_Dispatcher::getInstance()->disableView();

        $response = $this->getResponse();
        $response->setHeader("Content-Type", "application/json");
        $response->setBody(json_encode(array("name" => "yaf")));
        // Yaf sends the body after the dispatch loop finishes
    }
}
?>

See Also


<Yaf_Controller_Abstract::getRequestYaf_Controller_Abstract::getView>
^Yaf_Controller_AbstractLast updated: Mon, 26 Oct 2026