Data Export
Description
Data Export adds tracked XLSX export generation to Enso.
The package stores export state and progress, attaches the generated file to the Enso files system, supports both asynchronous query-based exports and synchronous in-memory exporters, and notifies users when the export finishes or fails.
It is designed for backoffice flows where long-running exports should be observable, cancellable, and retained for a configurable period.
Installation
Install the package:
composer require laravel-enso/data-export
Run the package migrations:
php artisan migrate
Optional publishes:
php artisan vendor:publish --tag=data-export-config
php artisan vendor:publish --tag=data-export-mail
Default configuration:
return [
'rowLimit' => env('EXPORT_ROW_LIMIT', 1000000),
'retainFor' => (int) env('EXPORT_RETAIN_FOR', 60),
];
The package schedules enso:data-export:purge daily.
Features
- Asynchronous XLSX exports based on a query builder.
- Synchronous export support for classic Enso Excel exporters.
- Export progress tracking and IO broadcasting support.
- File attachment and cleanup integration through
laravel-enso/files. - Hooks for setup, teardown, custom notifications, custom row actions, and custom sheet names.
- Cancel endpoint and automatic retention purge.
Usage
Implement the asynchronous exporter contract:
use Illuminate\Database\Eloquent\Builder;
use LaravelEnso\DataExport\Contracts\ExportsExcel;
class OrdersExport implements ExportsExcel
{
public function filename(): string
{
return 'orders.xlsx';
}
public function heading(): array
{
return ['Id', 'Number'];
}
public function query(): Builder
{
return Order::query();
}
public function attributes(): array
{
return ['id', 'number'];
}
public function mapping($row): array
{
return [$row->id, $row->number];
}
}
Dispatch the export through the model:
use LaravelEnso\DataExport\Models\Export;
Export::excel(new OrdersExport());
API
HTTP routes
PATCH api/export/{export}/cancel
Route name:
export.cancel
Artisan commands
enso:data-export:purge
Extension points
BeforeHookAfterHookCustomCountCustomMaxCustomMinCustomRowActionCustomSheetNameNotifies
Depends On
Required Enso packages:
laravel-enso/core↗laravel-enso/enums↗laravel-enso/files↗laravel-enso/helpers↗laravel-enso/io↗laravel-enso/track-who↗
Optional Enso companion package:
Required external package:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!