Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Exporter Laravel Package

sonata-project/exporter

SonataExporter is a lightweight PHP library for exporting data to multiple formats (CSV, XLS, JSON, XML). It provides writers, handlers, and iterators to stream large datasets efficiently and integrate easily into Symfony apps and services.

View on GitHub
Deep Wiki
Context7

Lightweight Exporter library

Frequently asked questions about Exporter
Can I use SonataExporter with Laravel 10 or 11 for CSV/JSON exports?
Yes, SonataExporter fully supports Laravel 10/11 due to its Symfony 7.x/8.x alignment. Install via Composer (`sonata-project/exporter`) and leverage Eloquent/Collections directly. No additional Laravel-specific setup is required beyond PHP 8.2+.
What happens if I’m still on PHP 8.1 with Laravel 9?
This release drops PHP 8.1 support, so it won’t work with Laravel 9. Upgrade to PHP 8.2+ or consider alternatives like `spatie/laravel-exports` (PHP 8.0+). Audit dependencies with `composer why-not php:^8.2` to identify blockers.
How do I export large Eloquent datasets without memory issues?
Use SonataExporter’s iterators and writers to stream data incrementally. For Eloquent, chain `cursor()` to avoid loading all records at once. Example: `$users->cursor()->each(fn($user) => $exporter->addRow($user->toArray()))`.
Does SonataExporter support Excel (XLS/XLSX) exports?
No, SonataExporter doesn’t include Excel support. For XLS/XLSX, pair it with `PhpOffice/PhpSpreadsheet` manually or use `maatwebsite/excel`, which offers built-in Excel features and Laravel integration.
Will this break if I use Doctrine DBAL <4.0 in Laravel?
Yes, this release requires Doctrine DBAL 4+. If you’re on an older version, test thoroughly for regressions or upgrade DBAL first. For Laravel apps using `spatie/laravel-doctrine-orm`, ensure compatibility with Doctrine 4.
Can I integrate SonataExporter with Laravel Queues for async exports?
No, SonataExporter lacks native queue support. Manually dispatch a job (e.g., `ExportDataJob`) that uses the exporter, then return a download link or notification. Example: `dispatch(new ExportDataJob($data))->onQueue('exports').`
What are the best alternatives if SonataExporter isn’t compatible?
For PHP 8.0+ Laravel apps, consider `spatie/laravel-exports` (active maintenance, queue support) or `maatwebsite/excel` (Excel-focused, feature-rich). Both integrate seamlessly with Eloquent and Collections.
How do I handle special characters or BOM issues in CSV/JSON exports?
SonataExporter doesn’t auto-handle BOM or encoding. Manually configure the writer’s charset (e.g., `new CsvWriter($stream, 'UTF-8')`) and validate edge cases. Test with `mb_detect_encoding()` for non-ASCII data.
Does SonataExporter work with Symfony components outside Laravel?
Yes, but Symfony 8.x is now required, which may conflict with older Symfony 7.x components. Audit your stack for version mismatches using `composer why symfony/*`. Replace or update conflicting packages first.
How do I migrate from an older SonataExporter version to this release?
Start by upgrading PHP to 8.2+. Replace any Symfony 7.x components with 8.x equivalents. Test Doctrine DBAL 4 if used, then gradually replace export logic. Use `composer update sonata-project/exporter` after verifying dependencies.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky