PHPackages                             redsquirrelstudio/laravel-backpack-export-operation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. redsquirrelstudio/laravel-backpack-export-operation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

redsquirrelstudio/laravel-backpack-export-operation
===================================================

An operation to make configurable exports for your CRUDs using the Backpack api you know and love

1.1.0(1y ago)72.1k↓33.3%4[1 issues](https://github.com/redsquirrelstudio/laravel-backpack-export-operation/issues)MITPHP

Since Jan 28Pushed 1y ago2 watchersCompare

[ Source](https://github.com/redsquirrelstudio/laravel-backpack-export-operation)[ Packagist](https://packagist.org/packages/redsquirrelstudio/laravel-backpack-export-operation)[ RSS](/packages/redsquirrelstudio-laravel-backpack-export-operation/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (14)Used By (0)

Export Operation for Backpack for Laravel
=========================================

[](#export-operation-for-backpack-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/686ec9c263650e36b134abd359d3efdcf268f397cde1545114f0041048b60b36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726564737175697272656c73747564696f2f6c61726176656c2d6261636b7061636b2d6578706f72742d6f7065726174696f6e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/redsquirrelstudio/laravel-backpack-export-operation)

Adds a configurable interface that allows your admin users to:

- Export CRUD resources to multiple file formats.
- Decide which columns they would like to export.
- Export data based on the filters applied in the CRUD's list operation

and allows you as the developer to:

- Customise each CRUD's export behaviour using the Backpack API you know and love.
- Choose between queued or instant exports.
- Completely customise the operation's behaviour.

[!["Buy Me A Coffee"](https://camo.githubusercontent.com/9f44ce2dc3b3eecdd02598900866ffc518801df1932849703dae1e5ce5031070/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/redsquirrelstudio)

If you're looking for a great team of developers to handle some Backpack/Laravel development for you, drop us a line at [Sprechen](https://sprechen.co.uk)

**Also need imports for your CRUD? Check out [redsquirrelstudio/laravel-backpack-import-operation](https://github.com/redsquirrelstudio/laravel-backpack-import-operation)**

[![Screenshot of the operation's configuration screen](https://raw.githubusercontent.com/redsquirrelstudio/laravel-backpack-export-operation/dev/assets/screenshot.png?raw=true)](https://raw.githubusercontent.com/redsquirrelstudio/laravel-backpack-export-operation/dev/assets/screenshot.png?raw=true)

Powering the exports in the background is [`maatwebsite/excel`](https://laravel-excel.com)

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Usage](#usage)
3. [Disabling User Configuration](#disabling-user-configuration)
4. [Queued Exports](#queued-exports)
5. [Configuration](#configuration)
    1. [File Storage](#file-storage)
    2. [Queues](#queues)
    3. [Changing the Export log Model](#export-log)
    4. [Customising Translations](#translations)
    5. [Customising Views](#views)
6. [Export Completed Event](#export-completed-event)
7. [Restricting Access](#restricting-access)
8. [Credits](#credits)
9. [License](#license)

Installation
------------

[](#installation)

**Environment Requirements**

- PHP extension php\_zip
- PHP extension php\_xml
- PHP extension php\_gd2
- PHP extension php\_iconv
- PHP extension php\_simplexml
- PHP extension php\_xmlreader
- PHP extension php\_zlib

**Step 1.**

Require the package with composer:

```
composer require redsquirrelstudio/laravel-backpack-export-operation
```

This will also install [`maatwebsite/excel`](https://laravel-excel.com) if it's not already in your project.

**Step 2. (Optional)**

If you would like to add the option to export PDFs, you should also install dompdf:

```
composer require dompdf/dompdf
```

**Step 3. (Optional)**

The service provider at: `RedSquirrelStudio\LaravelBackpackExportOperation\Providers\ExportOperationProvider`will be auto-discovered and registered by default. Although, if you're like me, you can add it to your `config/app.php`.

```
    'providers' => ServiceProvider::defaultProviders()->merge([
        /*
         * Package Service Providers...
         */
        //Some other package's service providers...
        RedSquirrelStudio\LaravelBackpackExportOperation\Providers\ExportOperationProvider::class,
    ])->toArray(),
```

**Step 4.**

Publish the config file:

```
php artisan vendor:publish --tag=laravel-backpack-export-operation-config
```

This will create a new file at `config/backpack/operations/export.php` allowing you to customise things such as the disk and path exported files should be stored at.

**Step 5.**

Publish and run the migration:

```
php artisan vendor:publish --tag=laravel-backpack-export-operation-migrations
```

*Then*

```
php artisan migrate
```

Usage
-----

[](#usage)

In your CRUD Controller where you need the export operation.

*Wait for it...*

**Add the export operation:**

```
class ExampleCrudController extends CrudController
{
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
    use \RedSquirrelStudio\LaravelBackpackExportOperation\ExportOperation;
    //...
```

But wait! There's more!

### Configuring the Export

[](#configuring-the-export)

Configuring the export is exactly the same as how you would configure the list operation. Simply define which columns you would like to export, here's an example:

```
    //Probably some more CRUD config...

    protected function setupExportOperation()
    {
        CRUD::addColumn([
           'name' => 'id',
           'label' => 'ID',
           'type' => 'number',
        ]);

        CRUD::addColumn([
           'name' => 'name',
           'label' => 'Name',
           'type' => 'text',
        ]);
    }

    //Fetch functions or something...
```

Pretty much all columns that are available for the list operation will work fine in an export. This also means you can define your own columns in the exact same way as you would with list columns.

For a list of available column types, [see Backpack for Laravel's Documentation](https://backpackforlaravel.com/docs/6.x/crud-columns)

Disabling User Configuration
----------------------------

[](#disabling-user-configuration)

Sometimes, you may not want the user to be able to choose which columns are included in their export, In these cases, you can disable the user configuration step.

To enable this behaviour, add this one line of code to the `setupExportOperation()` function:

```
    //...
    protected function setupExportOperation()
    {
        $this->disableUserConfiguration();
    //...
```

Queued Exports
--------------

[](#queued-exports)

In most situations, it is going to be better for the user if your exports are processed in the background rather than making them wait for the export to finish processing.

Therefore, you have the option to queue your exports by adding this line of code to the `setupExportOperation()` function:

```
    //...
    protected function setupExportOperation()
    {
        $this->queueExport();
    //...
```

When this option is enabled, you will need to handle what happens when the export finishes or the user will not receive their export. To do this, you should handle the `ExportCompleteEvent` using an event listener. This event contains the export log which you can get the file path from to send to the user via email, notification etc.

[Read about the export complete event here](#export-completed-event)

[Learn how to handle events on Laravel's official Docs](https://laravel.com/docs/10.x/events#defining-listeners)

Of course, for this to work, you will need to set up a queue for your application to dispatch jobs to, to do that, [follow Laravel's official docs](https://laravel.com/docs/queues).

When this setting has been enabled, the user will be redirected to the current CRUD's list view. An alert will appear in the top right which has a default message.

If you would like to change this message, add the following line to the `setupExportOperation()` function:

```
    //...
    protected function setupExportOperation()
    {
        $this->setQueueMessage("Your Message about the export being queued.");
    //...
```

Configuration
-------------

[](#configuration)

### File Storage

[](#file-storage)

By default, export files will be stored in your default disk at the path /exports. but this can be altered either by changing the following env variables:

```
FILESYSTEM_DISK="s3"
BACKPACK_EXPORT_FILE_PATH="/2024/application-name/exports"
```

Or by directly changing the options within `config/backpack/operations/export.php`.

```
    //...
    //Filesystem disk to store export files
    'disk' => "s3",

    //Path to store export files
    'path' => "/2024/application-name/exports",
    //...
```

### Queues

[](#queues)

You can also change the queue that queued exports are dispatched to by changing the following env variables:

```
QUEUE_CONNECTION="export-queue"
```

or changing the value directly within `config/backpack/operations/export.php`.

```
    //...
    //Queue to dispatch export jobs to
    'queue' => 'export-queue',
    //...
```

### Export Log

[](#export-log)

In very rare cases, you may wish to also change the model that is used to log exports, I can't think of a reason why, but I'm sure someone will come up with one.

If you do, make sure to update the migration, and specify your own model at `config/backpack/operations/export.php`.

```
//...
return [
    'export_log_model' => ExportLog::class,
    //...
```

### Translations

[](#translations)

You can update the operation translations if required. To do this run:

```
php artisan vendor:publish --tag=laravel-backpack-export-operation-translations
```

this will publish the operation lang files to `resources/lang/vendor/backpack/export-operation`The files stored in this directory take priority over the package's default lang files.

### Views

[](#views)

You can update the operation views if required. To do this run:

```
php artisan vendor:publish --tag=laravel-backpack-export-operation-views
```

this will publish the operation blade files to `resources/views/vendor/backpack/export-operation`The files stored in this directory take priority over the package's default views.

Export Completed Event
----------------------

[](#export-completed-event)

This package fires an event when an export has been completed. The event payload contains the export log so that you can send an email, notification or whatever else with a download url for the file.

##### Event Class:

[](#event-class)

```
RedSquirrelStudio\LaravelBackpackExportOperation\Events\ExportCompleteEvent::class
```

##### Payload:

[](#payload)

```
[
    //The Completed Export
   'export_log' => RedSquirrelStudio\LaravelBackpackExportOperation\Models\ExportLog::class
]
```

Restricting Access
------------------

[](#restricting-access)

Like most operations in Backpack, you can restrict user access using the following line of code in your CRUD Controller's setup function:

```
    public function setup()
    {
        //...
        CRUD::denyAccess('export');
        //...
    }
```

Credits
-------

[](#credits)

- [Lewis Raggett](https://github.com/redsquirrelstudio) and [The Team at Sprechen](https://sprechen.co.uk) :: Package Creator
- [Bad-Y](https://github.com/Bad-Y) :: Export Filter Support
- [Cristian Tabacitu](https://github.com/Laravel-Backpack) :: Backpack for Laravel Creator
- [Spartner](https://laravel-excel.com) :: Laravel Excel Creator
- [DomPDF](https://github.com/dompdf/dompdf) :: DOMPDF Creator

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~44 days

Recently: every ~73 days

Total

8

Last Release

531d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12d99ba1707a8cc5ab7d90aa1c54d9e1811fde70464f7edf08823adaf17872b9?d=identicon)[redsquirrelstudio](/maintainers/redsquirrelstudio)

---

Top Contributors

[![redsquirrelstudio](https://avatars.githubusercontent.com/u/46108903?v=4)](https://github.com/redsquirrelstudio "redsquirrelstudio (36 commits)")[![Bad-Y](https://avatars.githubusercontent.com/u/14094226?v=4)](https://github.com/Bad-Y "Bad-Y (7 commits)")

### Embed Badge

![Health badge](/badges/redsquirrelstudio-laravel-backpack-export-operation/health.svg)

```
[![Health](https://phpackages.com/badges/redsquirrelstudio-laravel-backpack-export-operation/health.svg)](https://phpackages.com/packages/redsquirrelstudio-laravel-backpack-export-operation)
```

###  Alternatives

[mediconesystems/livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS

1.2k711.3k8](/packages/mediconesystems-livewire-datatables)[backpack/settings

Application settings interface for Laravel 5 using Backpack CRUD.

290870.9k10](/packages/backpack-settings)[konnco/filament-import

241243.2k2](/packages/konnco-filament-import)[simonhamp/laravel-nova-csv-import

A fully-fledged CSV import tool for Laravel Nova.

167433.3k](/packages/simonhamp-laravel-nova-csv-import)[backpack/theme-tabler

UI for Backpack v6 that uses Tabler and Bootstrap v5.

35536.5k](/packages/backpack-theme-tabler)[ronasit/laravel-helpers

Provided helpers function and some helper class.

1475.7k13](/packages/ronasit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
