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
Laravel Datatables Export

Laravel Datatables Export Laravel Package

yajra/laravel-datatables-export

Server-side export plugin for yajra/laravel-datatables using queues, Livewire, and OpenSpout. Adds an export-button component and queued batch jobs to generate spreadsheet exports from DataTable classes on Laravel 13 (PHP 8.3+).

View on GitHub
Deep Wiki
Context7

Laravel DataTables Queued Export Plugin.

Frequently asked questions about Laravel Datatables Export
How do I add an export button to my existing Laravel DataTables view?
Use the `<livewire:export-button>` component in your Blade view, passing the DataTable’s ID via `:table-id`. Ensure your DataTable class extends `WithExportQueue` to enable queued exports. Example: `<livewire:export-button :table-id="$dataTable->getTableId()"/>`.
What Laravel and PHP versions does this package support?
This package requires **Laravel 13.x** and **PHP 8.3+** (PHP 8.4+ for OpenSpout 5.x). If you’re on Laravel 10/11, you’ll need to upgrade to Laravel 13. Check the [compatibility table](https://github.com/yajra/laravel-datatables-export) for older versions.
Do I need Livewire for exports? What if I don’t use Livewire?
Yes, this package **requires Livewire** for the export button component. If you’re not using Livewire, you’ll need to create a custom Blade component or AJAX endpoint to trigger exports via a controller, bypassing the Livewire dependency.
How do I handle large datasets (e.g., 50K+ rows) without memory issues?
The package uses **OpenSpout** for efficient streaming exports and **queued jobs** to avoid blocking requests. For very large datasets, configure chunking in your query (e.g., `->chunk(1000)`) and ensure your queue worker has sufficient memory. Monitor disk space if storing files locally.
What queue drivers are supported, and how do I set up workers?
Supported drivers include **Redis, database, and SQS**. Run `php artisan queue:work` to start workers. For high-volume exports, use Redis or a dedicated queue service. Ensure the `queue:batches-table` migration is run (`php artisan queue:batches-table && php artisan migrate`).
Can I export to formats other than CSV/XLSX, or is it limited to OpenSpout?
This package **only supports CSV and XLSX** via OpenSpout. If you need PDFs or other formats, consider integrating a separate library like **Barryvdh/Laravel-Snappy** or **Dompdf** alongside this package for hybrid workflows.
How do I store exported files on S3 instead of local disk?
Configure the `tmp_path` in `config/datatables-export.php` to point to an S3-compatible storage disk (e.g., `tmp_path => 's3://your-bucket/exports'`). Ensure your storage driver is properly set up in `config/filesystems.php` and the IAM role has write permissions.
What happens if the queue fails during an export? Can I retry or fallback to sync?
Failed jobs are retried automatically by Laravel’s queue system. For critical exports, implement a **fallback sync method** by extending the `ExportQueue` class or using a middleware to catch failures. Log errors via `Log::error()` for debugging.
How do I notify users when their export is ready (e.g., email or Livewire toast)?
Use Livewire’s `emit()` to show a toast notification when the export job completes. For emails, dispatch a `Mailable` in the job’s `handle()` method. Example: `ExportJob::dispatch($dataTable)->onQueue('exports');` then listen for job completion in Livewire.
Are there performance benchmarks for complex queries (e.g., joins, aggregations)?
Performance depends on your database and query complexity. Test with your actual data using `tntsearch/laravel-scout-tnt` for large datasets or optimize queries with indexes. For joins, consider denormalizing or caching results if exports run frequently.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony