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

Laravel5 Fractal Laravel Package

cyvelnet/laravel5-fractal

Laravel 5 Fractal offers a simple Laravel-friendly wrapper around League Fractal for transforming Eloquent models and collections into clean API responses, with reusable transformers, includes, serializers, and pagination support.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

  • Architecture fit: This is a thin Laravel convenience layer, not a framework. It provides a service provider that binds League\Fractal\Manager into the container, plus an Artisan make:transformer generator (and likely a config file/facade). The actual transformation logic lives in league/fractal. It fits Laravel's service-provider/container idiom cleanly, but its value is developer ergonomics, not architecture. It is trivially replaceable with ~50 lines of internal code, which materially lowers dependency risk. It only makes sense if the team has deliberately chosen Fractal's model (transformers, includes, sparse fieldsets, JsonApi/Array serializers) over Laravel's native API Resources.
  • Integration feasibility: Low friction. composer require cyvelnet/laravel5-fractal, rely on auto-discovery (Laravel 5.5+), optionally publish config, then generate transformers. No schema migrations, no infrastructure changes, no runtime service dependencies. A one-endpoint spike can validate fit in an afternoon.
  • Technical risk: Small, single-maintainer package (79 stars) with a low bus factor. Despite the "laravel5" name, the last release metadata is 2024-03-13, so actual Laravel/PHP support must be verified rather than assumed. The larger risk is upstream: league/fractal maturing/stagnating and drifting from current PHP/Laravel versions. Because the package is thin, "fork and own it" is a cheap mitigation. The main functional risk is silent output-shape differences (serializers, includes, null handling) relative to native resources.
  • Key questions:
    1. Do we actually need Fractal-only capabilities (JsonApi serializer, includes, sparse fieldsets, its pagination primitives)?
    2. Which Laravel/PHP versions are in our support matrix, and are both this package and league/fractal compatible?
    3. Are we standardizing org-wide on API Resources or Fractal? Mixing both creates inconsistency.
    4. Who owns an internal fork if upstream is abandoned?
    5. Is the generator's DX gain worth an extra dependency versus a homegrown stub generator?

Integration Approach

  • Stack fit: Best for Laravel 5.x–8.x era applications, or teams already committed to Fractal. Works wherever Composer and a supported PHP runtime exist, contingent on league/fractal constraints. For greenfield Laravel 9/10/11, native API Resources are the lower-risk default.
  • Migration path:
    • From hand-wired Fractal: replace manual Manager instantiation with the package binding, then verify byte-for-byte output parity via snapshot tests.
    • From this package to native resources: map each transformer to a JsonResource, map includes to whenLoaded/whenIncluded, replace serializers with resource wrapping; migrate endpoint by endpoint.
    • To a more active alternative: spatie/laravel-fractal has a similar surface if Fractal itself is required.
  • Compatibility: Pin exact versions. Confirm PHP 8.x and Laravel LTS support, verify league/fractal version constraints, and watch for deprecated null-serializer behavior and return-type changes. Run the full test suite against the target version matrix in CI.
  • Sequencing: (1) Spike one read-heavy endpoint. (2) Wire provider and config behind a branch. (3) Generate 2–3 transformers with golden-output JSON snapshots. (4) Eager-load relations to prevent N+1. (5) Roll out module by module behind a feature flag. (6) Reassess build-vs-fork after the spike before broad adoption.

Operational Impact

  • Maintenance: Minimal ongoing code, but real dependency hygiene: track league/fractal releases, security advisories, and PHP/Laravel EOL dates. Budget a small recurring review cadence; maintain an internal fork if upstream goes quiet. The thinness of the package means maintenance cost is mostly "watch upstream."
  • Support: No vendor SLA; community/author support only. Rely on our own tests and the Fractal documentation. Document the container binding and generator workflow in the internal handbook so knowledge doesn't concentrate in one engineer.
  • Scaling: Fractal serializes per request; overhead is generally acceptable but scales with collection size and include depth. Watch N+1 from includes, large unpaginated collections, and JsonApi serializer cost. Use eager loading and pagination; no inherent horizontal-scaling concerns.
  • Failure modes: Container binding conflicts if another package binds Fractal's Manager; version drift breaking transformers; the generator writing to unexpected namespaces/paths; abandonment blocking framework upgrades; output-shape regressions when Fractal changes defaults. Mitigations: golden-output tests, strict version pins, and an adapter layer so swapping to native resources is a one-file change.
  • Ramp-up: Fast for engineers who know Fractal (roughly a day to a first transformer). For teams only familiar with Eloquent API Resources, expect 2–4 days to absorb transformer/include/sparse-fieldset semantics and the generator workflow. Lowest-effort onboarding: a small internal example repo plus the golden tests as living documentation.
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.
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support