KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Anyone having an issue with headers on the Dashboard in Yii2 Framework? #3276

Closed Nick Perkins opened this topic on on Apr 3 - 6 comments

Nick Perkins commented on Apr 3

When loading the dashboard I am seeing this error message below the footer.

How can this be resolved?

An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /app/web/_protected/vendor/koolreport/dashboard/Response.php on line 176. in /app/web/_protected/vendor/yiisoft/yii2/web/Response.php:369
Stack trace:
#0 /app/web/_protected/vendor/yiisoft/yii2/web/Response.php(342): yii\web\Response->sendHeaders()
#1 /app/web/_protected/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /app/web/_protected/vendor/yiisoft/yii2/base/ErrorHandler.php(152): yii\web\ErrorHandler->renderException(Object(yii\web\HeadersAlreadySentException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\HeadersAlreadySentException))
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in /app/web/_protected/vendor/koolreport/dashboard/Response.php on line 176. in /app/web/_protected/vendor/yiisoft/yii2/web/Response.php:369
Stack trace:
#0 /app/web/_protected/vendor/yiisoft/yii2/web/Response.php(342): yii\web\Response->sendHeaders()
#1 /app/web/_protected/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#2 /app/web/public_html/index.php(19): yii\base\Application->run()
#3 {main}

Sebastian Morales commented on Apr 4

Would you mind posting your Yii2 controller's and your Dashboard App's php code? Tks,

Nick Perkins commented on Apr 16
<?php
//App.php

namespace app\reports;

use koolreport\dashboard\Application;
use koolreport\dashboard\inside\Yii2;


class App extends Application
{
    use Yii2;

    protected function onCreated()
    {
        $this->title('AHG Reports');
        $this->debugMode(true);

    }

    protected function sidebar()
    : array
    {
        return [
            "Members"=>MemberTable::create()->icon("fas fa-users"),
        ];
    }
}
<?php
namespace app\controllers;

use app\reports\App;
use yii\web\BadRequestHttpException;
use yii\web\Controller;

require_once __DIR__ .  "/../vendor/autoload.php";
require_once __DIR__ . "/../../_protected/reports/App.php";

class NewReportsController extends Controller
{
    public function beforeAction($action)
    : bool {
        $this->enableCsrfValidation = false;
        try {
            return parent::beforeAction($action);
        } catch (BadRequestHttpException $e) {
            return false;
        }
    }

    public function actionIndex()
    {
        App::create()->run();
    }
}
Nick Perkins commented on Apr 16

I am able to see the Dashboard now on initial load, HOWEVER when I click a pagination button, back button on detailAction, or search on the dashboard it just gives this error.

Nick Perkins commented on Apr 16

This is the MemberTable.php that is called.

KoolReport commented on Apr 17

Let try this:

    public function actionIndex()
    {
        App::create()->run();
        exit; //Exit immediately to avoid Yii2's attempt sending header and causing issue.
    }
Nick Perkins commented on Apr 17

That did it. I could have saved days of investigation if this was put into your docs for installation. Please do that for others. Thank you so much.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard