A Laravel wrapper for Fractal that simplifies API data transformation with an expressive syntax.
Spatie's Laravel Fractal is a wrapper package that integrates the Fractal transformation library into Laravel and Lumen applications. It simplifies the process of transforming data, such as Eloquent models or arrays, into structured JSON outputs suitable for APIs. The package provides an expressive syntax and helper methods to reduce boilerplate code when building API responses.
Laravel and Lumen developers building RESTful or JSON APIs who need to transform complex data structures into consistent, well-formatted JSON responses. It's particularly useful for backend developers working on API-driven applications.
Developers choose this package because it offers a more intuitive and Laravel-idiomatic way to use Fractal, with features like fluent chaining, direct Eloquent model transformation, and built-in response helpers. It reduces the complexity of raw Fractal usage while maintaining full flexibility.
An easy to use Fractal wrapper built for Laravel and Lumen applications
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers a chainable interface that simplifies data transformation compared to raw Fractal usage, as demonstrated in the README's code examples with methods like `includeCharacters()`.
Directly works with Eloquent models and collections, allowing easy transformation of database results without extra steps, such as `Users::all()->transformWith(new UserTransformer())`.
Includes a `respond()` method to return JSON responses with status codes and headers, streamlining API endpoint creation and reducing boilerplate code.
Configurable handling of include and exclude parameters from request data via the config file, reducing manual parsing boilerplate for dynamic API responses.
Relies on the Fractal library, adding another layer that must be maintained and understood, which can complicate debugging and increase project complexity.
The README documents several breaking changes between versions (e.g., v2 to v3 dropping Lumen support and config file renames), indicating potential upgrade challenges and maintenance headaches.
Primarily designed for Laravel, with Lumen support dropped in later versions, making it unsuitable for other PHP frameworks or non-Laravel projects.