box/spout
Fast, low-memory PHP library for reading and writing spreadsheet files (CSV, XLSX, ODS). Designed to handle very large files while using under ~3MB RAM. Requires PHP 7.2+, zip and xmlreader extensions. Archived/no longer maintained.
Strengths:
Weaknesses:
Storage::download()).spatie/laravel-queueable).phpoffice/phpspreadsheet or league/csv) with active maintenance.composer audit).Illuminate\Contracts\Container\BindingResolutionException).maatwebsite/excel).phpoffice/phpspreadsheet (active, feature-rich but heavier) or league/csv (CSV-only, active).microsoft/tnt (Microsoft’s PHP Excel library, if Windows/Linux parity is needed).maatwebsite/excel, spatie/laravel-medialibrary) that could conflict with Spout’s changes?WriterEntity to Laravel’s container, leveraging v3.3.0’s performance improvements:
$this->app->bind('spout.writer', function ($app) {
return \Box\Spout\Writer\Common\Creator\WriterEntityCreator::createXLSXWriter();
});
Spreadsheet facade to expose new features (e.g., Spreadsheet::toStrictXlsx()).spout.php options for:
'strict_ooxml' => env('SPOUT_STRICT_OOXML', true),
'chunk_size' => 5000, // Adjust for memory limits
public function handle() {
$writer = app('spout.writer');
$writer->openToFile(storage_path('app/report.xlsx'));
foreach (array_chunk($this->data, config('spout.chunk_size')) as $chunk) {
$writer->addRows($chunk);
}
$writer->close();
}
Storage facade with RFC6266-compliant headers for downloads:
return Storage::disk('s3')->download('report.xlsx', 'Report.xlsx', [
'headers' => ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
]);
fgetcsv or maatwebsite/excel).config('spout.enabled')).league/csv or phpoffice/phpspreadsheet for critical paths.use Box\Spout\Common\Exception\IOException;
try {
$reader = ReaderEntity::create(XLSX, $file);
} catch (IOException $e) {
abort(400, 'Invalid Excel file');
}
strict_types=1; report deprecation warnings.phpunit/phpunit@^9 with PHPUnit’s --testdox-html to document compatibility issues.HttpFoundation).Illuminate\Support\Collection methods (e.g., pluck() vs. Spout’s getRows()).symfony/event-dispatcher@^6 or psr/log@^1.box/spout in composer.json to ^3.3 and run composer why-not box/spout:^3.3.php -r "(new Box\Spout\Common\Type\FileType())->validate('file.xlsx');"
How can I help you explore Laravel packages today?