Fermin Perdomo

Senior Full Stack Engineer | PHP | JavaScript

Working with Laravel often means interacting with rich Eloquent models — but what happens when you need to export that data? Whether it's for auditing, backup, data sharing, or reporting, creating export logic from scratch can become repetitive and messy.

That's why we built laravel-model-export — a lightweight, elegant package that lets you export Eloquent models directly to JSON or PDF using a fluent and extensible API

✨ Features
  • ✅ Export any Eloquent model or query

  • 📝 JSON and PDF support (more coming soon!)

  • 🧱 Customize columns and transformations

  • 🔁 Supports lazy loading for huge datasets

  • ⚡ Clean and expressive syntax

  • Getting Started1. Install via Composer:composer require php-dominicana/laravel-model-export2. Publish the config (optional):php artisan vendor:publish --tag=model-export-config🧠 Basic UsageWant to export users to JSON?Or export to Excel?Done. 🎯💡 Advanced ExampleYou can also transform fields on the fly:And yes — the package supports streamed responses for large datasets via Laravel’s lazy() and chunk() behind the scenes.🛠 Under the HoodThe export process is powered by Laravel’s native features like:
  • StreamedResponse for low-memory JSON export

  • Support for query builders, model collections, or raw arrays

  • 📁 Use Cases
  • Exporting admin data from dashboards

  • Downloading reports for users

  • Building API endpoints for CSV/JSON data

  • Complying with user data portability (GDPR-style)

  • 🤝 ContributeWe’re actively improving this package! Want to add support for:
  • PDF?

  • Remote storage (e.g. S3)?

  • More layout control for PDFs?

  • Join us on GitHub:
    👉 github.com/PHP-Dominicana/laravel-model-export👋 Final Thoughtslaravel-model-export was built to remove the friction around exporting data in Laravel. Whether you’re building a dashboard, reporting tool, or admin panel, this package gives you an expressive and clean way to get data out of your models — without writing boilerplate.