Implementing the zipstream in our application because it gives me an error when zipping the exported data.
So far this what I have done
- composer require stechstudio/laravel-zipstream
- Copy & paste the example provided
- When I tried to export, it gives me an error “Class ‘STSZipStreamFacadesZip’ not found”
- Check my config/app.php, manually added the STSZipStreamZipStreamServiceProvider::class
Im following the instructions here https://github.com/stechstudio/laravel-zipstream?tab=readme-ov-file
Versions
- Using version ^4.14 for stechstudio/laravel-zipstream
- Laravel Framework 6.20.44
- php version 7.4.9
Controller
use STSZipStreamFacadesZip;
$zip = Zip::create('my_files.zip');
$zip->addFile('file1.txt', 'contents of file1');
$zip->addFileFromPath('path/to/file2.pdf', 'file2.pdf');
return response()->stream(function () use ($zip) {
$zip->finish();
}, 200, [
'Content-Type' => 'application/zip',
'Content-Disposition' => 'attachment; filename="my_files.zip"',
]);
How do I fix the error “Class ‘STSZipStreamFacadesZip’ not found”?”