PHPackages                             sinemacula/laravel-resource-exporter - 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. [API Development](/categories/api)
4. /
5. sinemacula/laravel-resource-exporter

ActiveLibrary[API Development](/categories/api)

sinemacula/laravel-resource-exporter
====================================

A versatile Laravel package for exporting JsonResource and JsonResourceCollection objects into various formats with customizable drivers.

v2.0.0(2mo ago)015.2k↓22.5%[1 PRs](https://github.com/sinemacula/laravel-resource-exporter/pulls)1Apache-2.0PHPPHP ^8.3CI passing

Since Aug 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/sinemacula/laravel-resource-exporter)[ Packagist](https://packagist.org/packages/sinemacula/laravel-resource-exporter)[ RSS](/packages/sinemacula-laravel-resource-exporter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (14)Versions (15)Used By (1)

Laravel Resource Exporter
=========================

[](#laravel-resource-exporter)

[![Latest Stable Version](https://camo.githubusercontent.com/7b9a7f08e324411cbb0ee67065102c99408811da2075295645ab372103a2b7ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e656d6163756c612f6c61726176656c2d7265736f757263652d6578706f727465722e737667)](https://packagist.org/packages/sinemacula/laravel-resource-exporter)[![Build Status](https://github.com/sinemacula/laravel-resource-exporter/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/sinemacula/laravel-resource-exporter/actions/workflows/tests.yml)[![Maintainability](https://camo.githubusercontent.com/e574aee2b27955176b9426a95d95292a833fe2a0f0dead8fca20093f9f35c3a7/68747470733a2f2f716c74792e73682f67682f73696e656d6163756c612f70726f6a656374732f6c61726176656c2d7265736f757263652d6578706f727465722f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/sinemacula/projects/laravel-resource-exporter)[![Code Coverage](https://camo.githubusercontent.com/715a60b1e368eda316b7875fc83454b48a6f50df5128023bf9ef4635c262410a/68747470733a2f2f716c74792e73682f67682f73696e656d6163756c612f70726f6a656374732f6c61726176656c2d7265736f757263652d6578706f727465722f636f7665726167652e737667)](https://qlty.sh/gh/sinemacula/projects/laravel-resource-exporter)[![Total Downloads](https://camo.githubusercontent.com/6da65f90e81b1a0ddb75d3f2401e253b6e968385038a32b06907bd2a20c113cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696e656d6163756c612f6c61726176656c2d7265736f757263652d6578706f727465722e737667)](https://packagist.org/packages/sinemacula/laravel-resource-exporter)

Laravel Resource Exporter is a Laravel integration package for converting `JsonResource` and `ResourceCollection` payloads into export-friendly formats.

The package includes:

- a manager (`ExportManager`) for resolving configured drivers
- built-in CSV and XML drivers
- a facade (`SineMacula\Exporter\Facades\Exporter`) for convenient usage
- extension hooks for custom export drivers without changing core package code

Features
--------

[](#features)

- Export arrays, single resources, and resource collections
- Select a driver explicitly (`csv`, `xml`) or use the configured default
- Exclude fields consistently across drivers using `withoutFields()`
- Customize per-driver options through `config/exporter.php`
- Register custom drivers via `ExportManager::extend()`

Supported Drivers
-----------------

[](#supported-drivers)

- `csv`
- `xml`

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

[](#installation)

To install the Laravel Resource Exporter, run the following command in your project directory:

```
composer require sinemacula/laravel-resource-exporter
```

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

[](#configuration)

After installation, publish the package configuration:

```
php artisan vendor:publish --provider="SineMacula\Exporter\ExporterServiceProvider"
```

This creates `config/exporter.php`, where you can control:

- `default`: the default exporter name
- `exporters`: named exporters and their `driver` + options
- `alias`: container/facade accessor alias (defaults to `exporter`)

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
use SineMacula\Exporter\Facades\Exporter;
use App\Http\Resources\YourResource;

// Export a single resource as CSV
$csv = Exporter::format('csv')->exportItem(new YourResource($item));

// Export a collection as XML
$xml = Exporter::format('xml')->exportCollection(YourResource::collection($collection));
```

### Field exclusion

[](#field-exclusion)

```
$csv = Exporter::format('csv')
    ->withoutFields(['internal_id', 'debug'])
    ->exportCollection(YourResource::collection($collection));
```

### On-demand exporters

[](#on-demand-exporters)

```
use SineMacula\Exporter\Facades\Exporter;

// Build an exporter from ad-hoc config
$exporter = Exporter::build([
    'driver' => 'csv',
    'delimiter' => ';',
]);
```

### Custom drivers

[](#custom-drivers)

```
use SineMacula\Exporter\ExportManager;

app(ExportManager::class)->extend('json', function ($app, array $config) {
    return new App\Exporters\JsonExporter($config);
});
```

Testing
-------

[](#testing)

```
composer test
composer test-coverage
composer check
```

Contributing
------------

[](#contributing)

Contributions are welcome via GitHub pull requests.

Security
--------

[](#security)

If you discover a security issue, please contact Sine Macula directly rather than opening a public issue.

License
-------

[](#license)

Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% 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 ~109 days

Recently: every ~137 days

Total

6

Last Release

87d ago

Major Versions

v1.1.2 → v2.0.02026-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/6262ea965c244b0c946a2f29a94da05e30846c066a0b59399466216654c78fe6?d=identicon)[sinemacula](/maintainers/sinemacula)

---

Top Contributors

[![sinemacula-ben](https://avatars.githubusercontent.com/u/118753672?v=4)](https://github.com/sinemacula-ben "sinemacula-ben (25 commits)")[![michaelstivala](https://avatars.githubusercontent.com/u/4493561?v=4)](https://github.com/michaelstivala "michaelstivala (1 commits)")

---

Tags

apilaravelexportresourcesine macula

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sinemacula-laravel-resource-exporter/health.svg)

```
[![Health](https://phpackages.com/badges/sinemacula-laravel-resource-exporter/health.svg)](https://phpackages.com/packages/sinemacula-laravel-resource-exporter)
```

###  Alternatives

[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[dragon-code/laravel-json-response

Automatically always return a response in JSON format

1118.6k1](/packages/dragon-code-laravel-json-response)[phpsa/laravel-postman

Export laravel API routes to postman

1014.7k](/packages/phpsa-laravel-postman)

PHPackages © 2026

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