Reputation: 1050
I am trying to download excel in laravel 5.2. But server is given this error
ReflectionException in Container.php line 734: Class excel does not exist
this work fine in localhost
this my function
return Excel::create('users', function($excel) use($datas) {
return $excel->sheet('Sheet 1', function($sheet) use($datas) {
$datasheet = array();
$datasheet[0] = array('id','Voucher No','Code','Expiry Date','Created_at');
$i=1;
foreach($datas as $datanew){
$datasheet[$i] = array( @$datanew['id'],
$datanew['vouchers_no'],
$datanew['code'],
$datanew['date'],
$datanew['created_at'],
);
$i++;
}
$sheet->fromArray($datasheet);
});
})->download('xlsx');
used packegeis
maatwebsite/excel
i am add this two line in config/app.php
Maatwebsite\Excel\ExcelServiceProvider::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
it work fine in localhost but showing error
Upvotes: 1
Views: 5966
Reputation: 1807
For me, this issue comes on GoDaddy server when I created a zip file of the vendor folder in laravel and replaced it with the server as I included new packages there. Nothing worked as ssh terminal was not enabled by the client for the final solution I deleted the files inside bootstrap/cache
and it worked perfectly.
Upvotes: 1
Reputation: 992
I got a similar behavior in my production server. Resolved by executing:
composer update
composer update --no-scripts
The first to update all objects ; the other to avoid the scripts execution that can be failed during update
Upvotes: 1