php-open-source-saver/fractal
Fractal is a maintained fork of thephpleague/fractal for transforming complex data into consistent API output. Provides a presentation layer with transformers, type casting, relationship includes, custom serializers, and pagination support for JSON/YAML APIs.
API Contract Stability: Adopt Fractal to enforce a strict separation between internal data models (e.g., Eloquent, Doctrine) and API responses. This ensures backward compatibility for clients (mobile apps, third-party services) when schema evolves, reducing churn and support costs.
Roadmap Prioritization:
users.posts.comments).Build vs. Buy:
include=posts).Key Use Cases:
foreach loops for relationships (e.g., UserTransformer with include=posts.comments).fields[user]=id,name) to optimize bandwidth for mobile clients.Adopt Fractal if:
thephpleague/fractal is stagnant).Look Elsewhere if:
json_encode or custom serializers)."Fractal is a battle-tested tool to future-proof our API investments. By adopting this package, we can:
"Fractal solves three critical pain points in our API:
foreach loops for relationships (e.g., User->posts->comments) with declarative includes (e.g., ?include=posts.comments).thephpleague/fractal for this maintained fork, and reuse existing transformers with minimal changes. Let’s pilot it on our /users endpoint to validate ROI.""Here’s how we’ll roll this out:
json_encode($model) in controllers with Fractal’s Manager for 2–3 high-traffic endpoints (e.g., /users, /posts).include params for nested data (e.g., GET /users?include=posts.comments).fields[user]=id,name) for mobile optimization.
Key benefits:/users to measure performance and developer productivity gains."How can I help you explore Laravel packages today?