Laravel-excel: Followed instructions but still Class 'Excel' not found

Created on 7 Aug 2015  路  10Comments  路  Source: Maatwebsite/Laravel-Excel

So I just tried installing on a Laravel 5.1 project.

I followed the instructions, everything went fine, but there was now files to be published.

Now the class Excel won't be found, no matter if i write Excel or Excel.

My composer.son looks like this:
"maatwebsite/excel": "~2.0"
config/app.php
'MaatwebsiteExcelExcelServiceProvider',
And
'Excel' => 'MaatwebsiteExcelFacadesExcel',

Should be fine.

If i check in vendor/composer/autoload_classmap.php
'MaatwebsiteExcelClassesCache' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Classes/Cache.php',
'MaatwebsiteExcelClassesFormatIdentifier' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Classes/FormatIdentifier.php',
'MaatwebsiteExcelClassesLaravelExcelWorksheet' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Classes/LaravelExcelWorksheet.php',
'MaatwebsiteExcelClassesPHPExcel' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Classes/PHPExcel.php',
'MaatwebsiteExcelCollectionsCellCollection' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Collections/CellCollection.php',
'MaatwebsiteExcelCollectionsExcelCollection' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Collections/ExcelCollection.php',
'MaatwebsiteExcelCollectionsRowCollection' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Collections/RowCollection.php',
'MaatwebsiteExcelCollectionsSheetCollection' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Collections/SheetCollection.php',
'MaatwebsiteExcelExcel' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Excel.php',
'MaatwebsiteExcelExcelServiceProvider' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php',
'MaatwebsiteExcelExceptionsLaravelExcelException' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Exceptions/LaravelExcelException.php',
'MaatwebsiteExcelFacadesExcel' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Facades/Excel.php',
'MaatwebsiteExcelFilesExcelFile' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExcelFile.php',
'MaatwebsiteExcelFilesExportHandler' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Files/ExportHandler.php',
'MaatwebsiteExcelFilesFile' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Files/File.php',
'MaatwebsiteExcelFilesImportHandler' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Files/ImportHandler.php',
'MaatwebsiteExcelFilesNewExcelFile' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Files/NewExcelFile.php',
'MaatwebsiteExcelFiltersChunkReadFilter' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Filters/ChunkReadFilter.php',
'MaatwebsiteExcelParsersCssParser' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/CssParser.php',
'MaatwebsiteExcelParsersExcelParser' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ExcelParser.php',
'MaatwebsiteExcelParsersViewParser' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Parsers/ViewParser.php',
'MaatwebsiteExcelReadersBatch' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Readers/Batch.php',
'MaatwebsiteExcelReadersConfigReader' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Readers/ConfigReader.php',
'MaatwebsiteExcelReadersHtml' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Readers/HtmlReader.php',
'MaatwebsiteExcelReadersLaravelExcelReader' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Readers/LaravelExcelReader.php',
'MaatwebsiteExcelWritersCellWriter' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Writers/CellWriter.php',
'MaatwebsiteExcelWritersLaravelExcelWriter' => $vendorDir . '/maatwebsite/excel/src/Maatwebsite/Excel/Writers/LaravelExcelWriter.php',

And in vendor/composer/autoload_namespaces.php

'MaatwebsiteExcel' => array($vendorDir . '/maatwebsite/excel/src'),

I'm out of ideas..
Why is this not working?
I found a thread on stack overflow, that guy solved it by using another VM.
I'd really not like to have to do that.

BTW, I'm on homestead.

Thanks.

Edit:
Did a clean install of a new laravel project, excel package worked fine. So there must be something weird going on in my original project.
Also tried pulling down the repo of my original project, did composer install. It pulled down everything.
But when i try Excel out it doesn't work. Still same error, class not found.

Most helpful comment

So after a lot of figuring and testing I found it to be a problem with the cached config files.
so I ran php artisan config:cache.
Now it's working.

All 10 comments

So after a lot of figuring and testing I found it to be a problem with the cached config files.
so I ran php artisan config:cache.
Now it's working.

@simtrax thank you very very much for sharing the solution!!! Had similar issue.. I almost gone mad.. THANKS!!!

@simtrax Thanks too!

Thanks a lot man for sharing this solution.

Thanks a lot for the help. Helped me a lot!

Thank you boss. refreshing cache works

@simtrax : Thank you brother for giving the solution.

Thanks. Somebody add it to "Getting Started" guide please.

thanks too

Add below line in your controller file
use MaatwebsiteExcelFacadesExcel;

Was this page helpful?
0 / 5 - 0 ratings