Search code examples
laravellaravel-5thephpleague-fractal

Eloquent: API Resources vs Fractal


Quick question, what is the difference between Eloquent: API Resources and Fractal?

To me, it looks like the same thing?


Solution

  • Both are used to transform API json responses to standardise the response structure.

    However, API resources is inbuilt in Laravel and it's very easy to use. Fractal was the preferred way to go when API resources were not in-build in Laravel. Fractal has some methods which make it little extensive as compared to API resources.

    But if you consider the core functionality, both are same with different syntactical sugar.

    Most of the things which were in fractal, you can do natively in Laravel now. Plus API resources eliminate the need of any extra installation and setup. The nomenclature is very easy in API resources to start with