spatie

spatie/laravel-fractal

PHP MIT Web Dev

An easy to use Fractal wrapper built for Laravel and Lumen applications

1.9k stars
184 forks
recent
GitHub

1.9k

Stars

184

Forks

0

Open issues

30

Contributors

6.4.0 21 Feb 2026

AI Analysis

A Laravel and Lumen wrapper around the Fractal data transformation library that simplifies API response formatting. It provides a fluent interface and multiple syntax options for transforming collections and Eloquent models into structured API outputs. Best suited for Laravel developers building REST APIs who need declarative data transformation without boilerplate.

Web Dev Library Discovery value: 3/10
Documentation 8/10
Activity 8/10
Community 8/10
Code quality 7/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

api-transformation laravel-package data-serialization rest-api fractal-wrapper
Actively maintained Well documented MIT licensed Niche/specialized use case Beginner friendly Production ready
Deep Analysis · Based on README and public signals
5d ago

Laravel wrapper for Fractal that simplifies API data transformation with minimal boilerplate

laravel-fractal is a thin, opinionated wrapper around the League/Fractal library designed to reduce boilerplate when transforming API responses in Laravel and Lumen applications. It targets Laravel developers who need structured, re-usable data transformation without writing verbose Fractal setup code. Adoption appears concentrated within Laravel ecosystem projects, particularly those using Spatie's ecosystem.

Origin

Created in October 2015, laravel-fractal emerged as Fractal was gaining traction for API response standardization. It positions itself as the 'Laravel way' to use Fractal, following Laravel's philosophy of developer ergonomics and convention over configuration.

Growth

Star count has plateaued significantly — zero growth in the last 7 days and modest star count (1,910) relative to similar Laravel packages. This suggests the project has reached a stable equilibrium within its niche rather than experiencing active expansion. The package remains actively maintained (last push 2026-06-26) but does not appear to be gaining new users at scale.

In production

Adoption not verified through public metrics. No case studies, testimonials, or documented large-scale deployments mentioned in README. Total Packagist downloads not quoted in provided metadata. Downloads badge present but count not extracted. Adoption likely exists within Spatie client base and Laravel ecosystem practitioners, but magnitude cannot be determined.

Code analysis
Architecture

Based on README, the package provides a fluent interface wrapper and helper functions (fractal(), Facade) around League/Fractal's Manager and Resource classes. It appears to handle Laravel Collection integration, auto-includes/excludes parsing from request parameters, and configurable serializers. Exact implementation details cannot be verified from README alone.

Tests

Not documented in README. CI badge present (run-tests workflow) but specific coverage metrics not provided.

Maintenance

Repository shows recent activity (last push 26 June 2026, 11 days before evaluation date). Packagist badge and GitHub Actions present suggest active maintenance cadence. However, maintenance appears to be reactive (bug fixes, Laravel version compatibility) rather than feature-driven, which is appropriate for a mature wrapper library.

Honest verdict

ADOPT IF: you are already using Fractal in Laravel projects and want to reduce boilerplate; your team values Spatie's ecosystem cohesion; you need request-driven include/exclude/fieldset parsing out of the box. AVOID IF: you are starting new API projects in 2026+ (consider spatie/laravel-data as Spatie's recommended approach for data transformation); you require actively growing community support or frequent feature releases; you are evaluating packages for greenfield projects where tooling decisions are not yet locked. MONITOR IF: you are maintaining a legacy Laravel codebase currently using laravel-fractal (remains stable; no urgent migration pressure); you are evaluating whether Spatie has positioned laravel-data as its successor (adoption signals unclear).

Independent dimensions

Mainstream potential

2/10

Technical importance

5/10

Adoption evidence

3/10

Risks
  • Potential obsolescence: Spatie maintains laravel-data (1,770 stars) as a more modern alternative using DTOs, suggesting laravel-fractal may not be recommended for new Spatie-aligned projects.
  • Fractal ecosystem dependency: Any breaking changes in League/Fractal would require matching adaptation; wrapper is vulnerable to upstream volatility.
  • Narrow use case: Only applicable to API response transformation; does not solve other common Laravel API concerns, limiting total addressable adoption.
  • Adoption plateau: Zero star growth in past 7 days and modest absolute count suggest the project has reached its market saturation within niche; unlikely to see inflection point.
  • Declining Laravel API conventions: If Laravel ecosystem shifts toward alternative transformation patterns (e.g., DTOs, attribute-based serialization), laravel-fractal's relevance may decline further.
Prediction

laravel-fractal will likely remain a stable, maintenance-mode package serving legacy codebases and developers with existing Fractal expertise. It is unlikely to gain significant new adoption; Spatie has signaled a direction shift toward laravel-data. The package will continue to receive compatibility updates for Laravel/Lumen LTS releases but should not be expected to evolve with new features.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

PHP
100%

Information

Language
PHP
License
MIT
Last updated
2w ago
Created
131mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Open issues

No open issues — clean slate.

Open pull requests

No open pull requests.

Similar repos

spatie

spatie/laravel-data

laravel-data provides a unified PHP object abstraction for Laravel...

1.8k PHP Web Dev
laravel

laravel/lumen-framework

Lumen is a micro-framework built on Laravel components, optimized for speed and...

1.5k PHP Web Dev
spatie

spatie/package-skeleton-laravel

This is a template repository for scaffolding Laravel packages, not a...

2.4k PHP Dev Tools
spatie

spatie/laravel-pdf

Laravel-pdf is a Laravel package that simplifies PDF generation by supporting...

1k PHP Web Dev
spatie

spatie/laravel-collection-macros

A curated collection of utility macros for Laravel collections that extend the...

1.9k PHP Web Dev
vs. alternatives
spatie/laravel-data

More recent Spatie offering (1,770 stars) that uses data transfer objects and attributes for type-safe transformation. Addresses similar domain but represents a different architectural philosophy — DTO-first vs. transformer-first. laravel-fractal may be considered legacy in favor of laravel-data for new Spatie projects.

laravel/sanctum

Different domain (API authentication) but higher star count (2,969) indicates broader Laravel adoption. Not a direct competitor but represents the adoption level of more recent/central Laravel packages.

Manual Fractal usage

Developers can use League/Fractal directly in Laravel. laravel-fractal's value is syntactic convenience and convention defaults, not new capability. Switching cost is low, making adoption more about developer preference than lock-in.

JSON:API compliance libraries

Standalone JSON:API libraries may handle transformation + serialization in one step. laravel-fractal depends on Fractal for serialization logic, potentially adding indirection vs. unified solutions.

Spatie/fractalistic

Parent library (framework-agnostic wrapper around Fractal) that laravel-fractal builds upon. laravel-fractal is the Laravel-specific adaptation; developers using Laravel gain Laravel integration but are not gaining new Fractal capabilities.