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
✅ 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
composer require php-dominicana/laravel-model-export
2. 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
Exporting admin data from dashboards
Downloading reports for users
Building API endpoints for CSV/JSON data
Complying with user data portability (GDPR-style)
PDF?
Remote storage (e.g. S3)?
More layout control for PDFs?
👉 github.com/PHP-Dominicana/laravel-model-export👋 Final Thoughts
laravel-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.