S
S
sv82016-05-02 12:26:24
phpspreadsheet
sv8, 2016-05-02 12:26:24

Why doesn't Laravel load the maatwebsite/excel class?

It is necessary to implement export to Excel.
I use: laravel + maatwebsite/excel package, I work on ubunt'e.
I'm trying to do an elementary export:

<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use Maatwebsite\Excel\Facades\Excel as Excel;

class Statistic extends Controller
{
    public function export()
    {
        Excel::create('Laravel_Excel', function($excel) {
            $excel->sheet('Excel_sheet', function($sheet) {
                $sheet->setOrientation('landscape');
            });
        })->export('xls');
    }
}

During debugging, it was revealed that everything is failing in the resolveFacadeInstance method, in the Facade.php class, on the line: return static::$resolvedInstance[$name] = static::$app[$name];
Those. fails to execute static::$app[$name]; (in $name 'excel' is passed)
In the providers and aliases in the config/app.php file, I registered everything, as in the instructions.
There is an excel.php file in the config/ folder.
I also tried composer dump-autoload.
Nothing helps.
People who know, tell me please, what could be the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
D', 2016-05-02
@Denormalization

And if you try directly, through:
app()->make('Maatwebsite\Excel\Excel') or app()->make('excel')?

A
Andrey Sokolov, 2016-05-02
@eX1stenZ

composer dump-autoload

M
Mokhirjon Naimov, 2016-05-03
@zvermafia

use Maatwebsite\Excel\Facades\Excel as Excel; // ?
It also works with Excel (that is, without `as Excel`).
If it were for example like this:
It would make sense to shorten `SomeLongerExcelPackageName` to `Excel`. I.e:
Well that's a note ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question