KoolReport's Forum

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

Main(): Failed opening required #1396

Closed Menaka Perera opened this topic on on Apr 20, 2020 - 2 comments

Menaka Perera commented on Apr 20, 2020

I am getting below when I try to run my sample report page developed using Laravel.

Symfony\Component\ErrorHandler\Error\FatalError
main(): Failed opening required 'C:\xampp\htdocs\Mena\app\Reports/koolreport/core/autoload.php' (include_path='C:\xampp\php\PEAR')

find below my source files

// ------ Web php ------

Route::get('/report', "ReportController@index");

//------ ReportController.php ------

<?php
// ReportController.php
namespace App\Http\Controllers;

use App\Reports\MyReport;

class ReportController extends Controller
{
    public function __contruct()
    {
        $this->middleware("guest");
    }
    
    public function index()
    {
        $report = new MyReport;
        $report->run();
        return view("report",["report"=>$report]);
    }
}

MyReport.php

<?php
namespace App\Reports;
use \koolreport\laravel\Friendship;

require_once __DIR__."/koolreport/core/autoload.php";

class MyReport extends \koolreport\KoolReport
{
    //We leave this blank to demo only
}

MyReport.view.php == Expected Output.

<html>
    <head>
    <title>My Report</title>
    </head>
    <body>
        <h1>It works</h1>
    </body>
</html>
KoolReport commented on Apr 20, 2020

You have include wrong path to the "autoload.php", this line of code is not correct yet:

require_once __DIR__."/koolreport/core/autoload.php";

The DIR pointing to the folder "app\Reports" and there is no "koolreport" folder inside there. I guess you need to use relative path for example __DIR__."/../../koolreport/core/autoload.php" to point to the correct folder where you put the "koolreport" library. Please change according to your folder structure.

If you use Laravel, you may try to install package with composer then you do not need this require_once command, since the koolreport will be loaded automatically with Laravel on start.

Another comment: The command use \koolreport\laravel\Friendship; should be used inside the report class:

class MyReport extends \koolreport\KoolReport
{
    //We leave this blank to demo only
    use \koolreport\laravel\Friendship;
}

Let us know if you need further assistance.

Menaka Perera commented on Apr 21, 2020

It is working. Thank you.

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
solved

None