Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Formatter

Laravel Formatter Laravel Package

soapbox/laravel-formatter

Laravel Formatter converts arrays, collections, and Eloquent models into JSON, XML, CSV, YAML, and other formats. It provides a simple, extensible API, customizable formatters, and clean output handling for exporting data in Laravel applications.

View on GitHub
Deep Wiki
Context7

A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class

Frequently asked questions about Laravel Formatter
What does soapbox/laravel-formatter do?
It is a formatter class for Laravel, derived from FuelPHP's Formatter, that converts arrays, collections, and Eloquent models into output formats such as JSON, XML, CSV, and YAML. It provides a simple, extensible API with customizable formatters for exporting data. Architecturally it is a presentation and serialization utility rather than domain infrastructure, so it should sit behind a narrow adapter instead of being called directly throughout the codebase.
Which Laravel and PHP versions does soapbox/laravel-formatter support?
The package is described as a Formatter Class for Laravel 4, and its last release was published on 2018-06-27. Its composer.json constraints target that era of Illuminate components and PHP, so compatibility with Laravel 5 and especially Laravel 9, 10, or 11 is unlikely without a fork. Always verify the constraints against your target PHP and Illuminate versions before committing.
How do I install soapbox/laravel-formatter with Composer?
The usual command is composer require soapbox/laravel-formatter, ideally run in a disposable branch first so you can see exactly what Composer resolves or conflicts on. On a Laravel 4 application you may need to register the package's service provider and any facade alias manually in config/app.php. Do a time-boxed proof-of-concept install before touching a real application, and do not assume compatibility from the release date alone.
How do I convert an Eloquent model or collection to JSON with this package?
You pass the array, collection, or model to the formatter and request the json format, which serializes it in a single call. Because the package predates modern Laravel conventions, keep every such call in one place, such as an internal FormatterInterface or adapter, rather than scattering it through controllers and models. That wrapper is also what lets you swap in response()->json() or API resources later.
Which output formats does soapbox/laravel-formatter support?
The documented formats are JSON, XML, CSV, YAML, and other formats through the same extensible API. Formatting is format-only: the package is not a parser or unformatter, so do not rely on it to read data back into arrays or models. Confirm that each format you actually need behaves correctly with golden-file tests before adopting it.
Can I add a custom formatter to soapbox/laravel-formatter?
The package advertises a simple, extensible API and customizable formatters, so you can supply your own formatter implementation for a bespoke output shape. Because the project is effectively unmaintained, any custom formatter becomes your responsibility to test and maintain. Keep custom formatters in your own codebase rather than patching vendor files, so the package can be removed cleanly later.
Is soapbox/laravel-formatter maintained and safe for production?
No, the last release was 2018-06-27, the repository has roughly 247 stars and low ecosystem leverage, and the package is tied to a long-EOL Laravel generation. Risks include an abandoned upstream, old Illuminate and PHP constraints that can block framework upgrades, missing security patches, and unclear behavior for edge cases such as encoding, CSV injection, and XML or YAML handling. Adopting it new in a current stack is not advisable; it is only low-burden inside a frozen legacy Laravel 4 application with no upgrade path.
What should I use instead of soapbox/laravel-formatter in modern Laravel?
For JSON, use response()->json() or Laravel API resources. For CSV, use league/csv; for structured serialization, symfony/serializer; and for XML or YAML, maintained XML/array libraries and symfony/yaml. These are actively maintained, integrate with current Laravel versions, and cover the same formatting need without pulling in a legacy dependency.
How do I migrate an existing application away from soapbox/laravel-formatter?
Inventory every call site and the exact formats in use, then isolate them behind an internal FormatterInterface or adapter and pin the exact package version. Add characterization or golden-file tests for JSON, XML, CSV, YAML, and error cases so any replacement must produce identical output. Then swap the adapter implementation for native or maintained libraries, cut over call sites incrementally, and remove the package once the last legacy path is retired. Formatting is typically stateless, so no data migration should be required.
Does soapbox/laravel-formatter handle large exports and user-supplied data safely?
Formatting runs in-process and builds full payloads in memory, which is memory-intensive for large arrays and objects, especially XML and YAML; stream large CSV exports with league/csv instead. There is no documented hardening for CSV injection, XML external entities, or YAML object deserialization, so validate and escape user-supplied data yourself. Treat the package as presentation only and never let it define your security posture.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect