在Laravel 5外使用立面(在CodeIgniter中)

时间:2019-06-07 12:44:37

标签: php laravel codeigniter maatwebsite-excel

我正在尝试使用Laravel软件包(maatwebsite / excel)在CodeIgniter上工作。
我得到的错误是:Message: A facade root has not been set.

有没有办法让Laravel外墙在CodeIgniter下工作?

我读了这篇文章:https://www.sitepoint.com/how-laravel-facades-work-and-how-to-use-them-elsewhere/向我暗示我需要打电话

Illuminate\Support\Facade::setFacadeApplication($app);

但是$app应该是什么?

到目前为止,我的代码是:

// Report.php
class Rapportage extends MY_Controller {
    public function __construct()
    {
        parent::__construct();

        // This doesn't work, what should I put here?
        Illumiante\Support\Facade::setFacadeApplication($app);
    }

    public function generate_rapport()
    {
        // This is where the error occurs
        return Excel::download(new PersonExport, 'rapport.xlsx');
    }
}

// Reports/Persons.php
namespace Exports;

use Person;
use Maatwebsite\Excel\Concerns\FromCollection;

class PersonExport implements FromCollection
{
    public function collection()
    {
        return Person::all();
    }
}

0 个答案:

没有答案