Laravel-excel: [BUG] Class excel does not exist

Created on 5 Apr 2017  路  12Comments  路  Source: Maatwebsite/Laravel-Excel

Package version, Laravel version

Laravel-Excel v2.1.17
Laravel v5.4.17

Expected behaviour

Work

Actual behaviour

Not working

Exception stack trace

ReflectionException in Container.php line 719:
Class excel does not exist
in Container.php line 719
at ReflectionClass->__construct('excel') in Container.php line 719
at Container->build('excel') in Container.php line 598
at Container->resolve('excel') in Container.php line 567
at Container->make('excel') in Application.php line 708
at Application->make('excel') in Facade.php line 221
at Facade::__callStatic('make', array('excel')) in AdminFeedbackController.php line 89
at AdminFeedbackController->excel()
at call_user_func_array(array(object(AdminFeedbackController), 'excel'), array()) in Controller.php line 55
at Controller->callAction('excel', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(AdminFeedbackController), 'excel') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AuthenticateWithBasicAuth.php line 38
at AuthenticateWithBasicAuth->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 561
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 520
at Router->dispatchToRoute(object(Request)) in Router.php line 498
at Router->dispatch(object(Request)) in Kernel.php line 174
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in TransformsRequest.php line 30
at TransformsRequest->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ValidatePostSize.php line 27
at ValidatePostSize->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
at require_once('/home/web/PhpstormProjects/nda/public/index.php') in server.php line 21

Screenshot of Excel file

No

Steps to reproduce the behaviour

I've installed it with composer, then I put provider and alias strings where they belong.
I've tried both App::make('excel'); and Excel::create('Something'); options, each time I'm getting that Class excel does not exist error. Composer updates and autoload dumps doesn't help either.

Most helpful comment

To clean cache config, on laravel 5.4 excecute:

php artisan cache:clear
php artisan config:cache

This solved the same problem... Thanks patrickbrouwers!

All 12 comments

Are you sure you include the service provider? It sounds like it isn't loaded.

Can you paste the relevant parts op config/app.php

Same exact issue: Laravel 5.4 on 5.3 works fine

use Maatwebsite\Excel\Facades\Excel;

app.php:

Maatwebsite\Excel\ExcelServiceProvider::class,

'Excel' => Maatwebsite\Excel\Facades\Excel::class,

$this->uploadedFile = Excel::load('storage/app/' . $this->uploadedFile, function ($reader) {
})->get();

ReflectionException in Container.php line 719: Class excel does not exist

Perhaps your config is cached?

yes that seems to fix that thanks

To clean cache config, on laravel 5.4 excecute:

php artisan cache:clear
php artisan config:cache

This solved the same problem... Thanks patrickbrouwers!

I tried but
Not yet fixed

[2018-05-15 04:59:08] lumen.ERROR: ReflectionException: Class excel does not exist in /var/www/html/server/vendor/illuminate/container/Container.php:752
Stack trace:

0 /var/www/html/server/vendor/illuminate/container/Container.php(752): ReflectionClass->__construct('excel')

1 /var/www/html/server/vendor/illuminate/container/Container.php(631): Illuminate\Container\Container->build('excel')

2 /var/www/html/server/vendor/illuminate/container/Container.php(586): Illuminate\Container\Container->resolve('excel', Array)

3 /var/www/html/server/vendor/laravel/lumen-framework/src/Application.php(230): Illuminate\Container\Container->make('excel', Array)

4 /var/www/html/server/vendor/illuminate/container/Container.php(1195): Laravel\Lumen\Application->make('excel')

5 /var/www/html/server/vendor/illuminate/support/Facades/Facade.php(159): Illuminate\Container\Container->offsetGet('excel')

6 /var/www/html/server/vendor/illuminate/support/Facades/Facade.php(128): Illuminate\Support\Facades\Facade::resolveFacadeInstance('excel')

7 /var/www/html/server/vendor/illuminate/support/Facades/Facade.php(215): Illuminate\Support\Facades\Facade::getFacadeRoot()

8 /var/www/html/server/app/Http/Controllers/ItemController.php(28): Illuminate\Support\Facades\Facade::__callStatic('load', Array)

9 [internal function]: App\Http\Controllers\ItemController->import(Object(Illuminate\Http\Request))

10 /var/www/html/server/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)

11 /var/www/html/server/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

12 /var/www/html/server/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))

13 /var/www/html/server/vendor/illuminate/container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)

14 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(373): Illuminate\Container\Container->call(Array, Array)

15 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(339): Laravel\Lumen\Application->callControllerCallable(Array, Array)

16 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(313): Laravel\Lumen\Application->callLumenController(Object(App\Http\Controllers\ItemController), 'import', Array)

17 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(275): Laravel\Lumen\Application->callControllerAction(Array)

18 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(260): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)

19 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(160): Laravel\Lumen\Application->handleFoundRoute(Array)

20 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(Object(Illuminate\Http\Request))

21 /var/www/html/server/vendor/laravel/lumen-framework/src/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

22 /var/www/html/server/app/Http/Middleware/CorsMiddleware.php(30): Laravel\Lumen\Routing\Pipeline->Laravel\Lumen\Routing{closure}(Object(Illuminate\Http\Request))

23 /var/www/html/server/vendor/illuminate/pipeline/Pipeline.php(149): App\Http\Middleware\CorsMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))

24 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

25 /var/www/html/server/vendor/laravel/lumen-framework/src/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))

26 /var/www/html/server/vendor/illuminate/pipeline/Pipeline.php(102): Laravel\Lumen\Routing\Pipeline->Laravel\Lumen\Routing{closure}(Object(Illuminate\Http\Request))

27 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(410): Illuminate\Pipeline\Pipeline->then(Object(Closure))

28 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(166): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))

29 /var/www/html/server/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(107): Laravel\Lumen\Application->dispatch(NULL)

30 /var/www/html/server/public/index.php(28): Laravel\Lumen\Application->run()

31 {main}

Same issue i have...laravel 5.4 and mattweb version 2.1.0

Is this problem resolved?

@pipat1995 this bug still happening, somehow the service provider does not get registered during tests... you can manually add Maatwebsite\Excel\ExcelServiceProvider::class, in your config/app.php to solve this issue

Class Maatwebsite\Excel\Cache\CacheManager does not exist

Can Anyone help me why i keep getting this error. It works fine on my local machine but pop up error message when live on the server. I have installed and followed all the steps required for maatwebsite Excel package. I am using laravel 5.5 version.

The order of operations is important here. Add the service provider and the class alias to app/config.php:

# app/config.php:
'providers' => [
Maatwebsite\Excel\ExcelServiceProvider::class,
]

'aliases' => [
'Excel' => Maatwebsite\Excel\Facades\Excel::class
]

THEN run the artisan cache and config commands on the production server.

php artisan cache:clear
php artisan config:cache

Was this page helpful?
0 / 5 - 0 ratings