Skip to content
Icon

WARNING You're browsing the documentation for an upcoming version of Laravel DataTables. The documentation and features of this release are subject to change.

Export Plugin Installation

GitHub: yajra/laravel-datatables-export

This package is a plugin for Laravel DataTables that handles server-side exporting using Queue, OpenSpout, and Livewire. It allows you to export large datasets without timing out by processing exports in background jobs.

[!NOTE] Requirements:

  • PHP 8.3+
  • Laravel 13.x
  • Livewire 3.x
  • A queue worker (Redis, Database, SQS, etc.)

Quick Installation

Install the package via Composer:

composer require yajra/laravel-datatables-export:"^13.0"

Queue Setup

The export package uses Laravel's job batching feature. You need to set up the queue and batch jobs tables:

# Create the jobs table (if not already exists)
php artisan queue:table
 
# Create the job batches table (required for export tracking)
php artisan queue:batches-table
 
# Run migrations
php artisan migrate

Configuration

[!NOTE] This step is optional. The package works with default configuration out of the box.

Publish the configuration file and views to customize the export behavior:

php artisan vendor:publish --tag=datatables-export --force

Configuration Options

After publishing, you can customize the export behavior in config/datatables-export.php:

<?php
 
return [
/*
* Query iteration method: 'lazy' (recommended for large datasets) or 'cursor'
*/
'method' => 'lazy',
 
/*
* Chunk size when using lazy method
*/
'chunk' => 1000,
 
/*
* Storage disk for export files
*/
'disk' => 'local',
 
/*
* Optional S3 disk for final destination
*/
's3_disk' => '',
 
/*
* Default date format for exports
*/
'default_date_format' => 'yyyy-mm-dd',
 
/*
* Auto-purge exports older than X days
*/
'purge' => [
'days' => 1,
],
];

Next Steps