PHPackages                             leyton/clevexport - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. leyton/clevexport

ActiveLibrary[File &amp; Storage](/categories/file-storage)

leyton/clevexport
=================

A Clever mechanism to export large data asynchronously

v1.1(3y ago)52145[4 issues](https://github.com/cognitx-leyton/clevexport/issues)Apache-2.0PHPPHP &gt;=7.4CI failing

Since Feb 24Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/cognitx-leyton/clevexport)[ Packagist](https://packagist.org/packages/leyton/clevexport)[ RSS](/packages/leyton-clevexport/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Clevexport
==========

[](#clevexport)

***Async Excel export for large Laravel datasets -- chunked, queued, and crash-free.***

[![License](https://camo.githubusercontent.com/705496698edfb46014993a563f6615efaadcc7282c90035e769a790e1957f6b6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f676e6974782d6c6579746f6e2f636c65766578706f72743f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/705496698edfb46014993a563f6615efaadcc7282c90035e769a790e1957f6b6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f676e6974782d6c6579746f6e2f636c65766578706f72743f7374796c653d666c61742d737175617265)[![Stars](https://camo.githubusercontent.com/a7f8e9ced0b6637f559b926c6264484f7a3331af4e29a3b7dc88582287cdd96f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f636f676e6974782d6c6579746f6e2f636c65766578706f72743f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/a7f8e9ced0b6637f559b926c6264484f7a3331af4e29a3b7dc88582287cdd96f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f636f676e6974782d6c6579746f6e2f636c65766578706f72743f7374796c653d666c61742d737175617265)[![PHP](https://camo.githubusercontent.com/f265e4d6593dbc6590fa3fe11928b5330e90111394e0e4918b3badb07923ddc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e342d3838393242463f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/f265e4d6593dbc6590fa3fe11928b5330e90111394e0e4918b3badb07923ddc9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344372e342d3838393242463f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Laravel](https://camo.githubusercontent.com/fac4cdfe5cc77471cb2df5fc0e0d436d8145d5dc46ae8262eafab691cef63455/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d362e782d2d382e782d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/fac4cdfe5cc77471cb2df5fc0e0d436d8145d5dc46ae8262eafab691cef63455/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d362e782d2d382e782d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)

---

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

[](#table-of-contents)

- [Motivation](#motivation)
- [Installation](#installation)
- [Usage](#usage)
- [Exportable](#exportable)
- [Transformer](#transformer)

---

Motivation
----------

[](#motivation)

The goal of this Laravel package is to execute the exportation to **EXCEL** large data/records that may cause in the crash of the server or a timeout. The idea is to divide the process in sub operations managable and easy to perform.

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

[](#installation)

```
compose require leyton/clevexport

```

After the installation make sure to publish the assets

```
php artisan vendor:publish --provider="Leyton\ClevExportServiceProvider"

```

You will find the `config/clevexport.php` file containing all the configurations needed.

```
return [
    // array of listeners that will be executed once the execution is done
    'listeners' => [],

    // if you want to stock the user who started the export
    'with_owner' => true,

    // the guard
    'guard' => 'web',

    // the foreign key name in the exports table
    'owner_id' => 'user_id',

    // The Authenticable class
    'owner_class' => \App\Models\User:class,

    // Number of chunks
    'chunks' => 10,
];
```

Then you can run your migration

```
php artisan migrate

```

Usage
-----

[](#usage)

The `QueryFinder` should be provided with an instance of an object that implements the `IseExportable` Interface

```
 $dossierExporter = QueryFinder::getInstance($this->defaultDossierService, $this->transformer);

 PreparingExportJob::dispatch($dossierExporter, $request->all())->delay(now()->addSecond());
```

A second Parameter is optional and if is provided it should implement the `ShouldHandleResult` It is where you can perform extra work on the results and provide the headers in a `ExportTransformed` container If the second parameter is not provided then the headers will be the column names selected from the query.

Exportable
----------

[](#exportable)

```
class UserExportable implements IsExportable
{

    /**
     * @param array $params
     * @return Builder
     */
    public function query(array $params): Builder
    {
        return  User::select('id', 'name', 'email')
            ->addSelect([
                'title' => Post::selectRaw('SUBSTRING(`content`, 1, 10) as `title`')->limit(1)
            ]);
    }
}
```

Transformer
-----------

[](#transformer)

```
class UserTransformer implements ShouldHandleResult
{

    public function transform($data): ExportTransformed
    {
        $data =   $data->map(function(User $user){
            $user->most_commented = optional($user->posts()->withCount('comments')->first())->comments_count;
            $user->comments_count = $user->comments()->count();
            $user->posts_count = $user->posts()->count();
            return $user;
        });

        return  new ExportTransformed(['id', 'name', 'email', 'title', 'Most commented', 'Comments count', 'Posts count'], $data->toArray());
    }
}
```

---

License
-------

[](#license)

This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.

---

 Built with care by [Leyton CognitX](https://cognitx.leyton.com/)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance54

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~305 days

Total

2

Last Release

1285d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fbeb774293770efe72dfe486b323e999e6d65d0df0db9052a1e5b76d9711efe?d=identicon)[akiyamaSM](/maintainers/akiyamaSM)

![](https://avatars.githubusercontent.com/u/6362694?v=4)[Mehdi BENJELLOUN](/maintainers/medito)[@medito](https://github.com/medito)

---

Top Contributors

[![akiyamaSM](https://avatars.githubusercontent.com/u/12276076?v=4)](https://github.com/akiyamaSM "akiyamaSM (5 commits)")[![medito](https://avatars.githubusercontent.com/u/6362694?v=4)](https://github.com/medito "medito (5 commits)")[![MehdiAroui](https://avatars.githubusercontent.com/u/10630880?v=4)](https://github.com/MehdiAroui "MehdiAroui (2 commits)")

---

Tags

asyncbackground-jobsbulk-exportdata-exportexcel-exportlaravellaravel-excellaravel-packagelarge-datasetphpqueue-jobsspreadsheet

### Embed Badge

![Health badge](/badges/leyton-clevexport/health.svg)

```
[![Health](https://phpackages.com/badges/leyton-clevexport/health.svg)](https://phpackages.com/packages/leyton-clevexport)
```

###  Alternatives

[illuminate/filesystem

The Illuminate Filesystem package.

16165.0M3.2k](/packages/illuminate-filesystem)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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