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
Laravel Datatables Fractal

Laravel Datatables Fractal Laravel Package

yajra/laravel-datatables-fractal

Laravel DataTables plugin that transforms server-side responses using Fractal transformers. Requires PHP 8.2+ and Laravel 12.x. Install via Composer and register the optional service provider to get started.

View on GitHub
Deep Wiki
Context7

Laravel DataTables Fractal is a plugin for yajra/laravel-datatables that integrates the Fractal transformation layer, letting you shape server-side DataTables responses with reusable transformers instead of ad-hoc array mapping. Install it via Composer and optionally register the service provider or publish the config.

  • Transform rows using Fractal transformers and serializers
  • Works with Eloquent, Query Builder, and Collection sources
  • Supports includes, excludes, and nested relationships
  • Publishable config for default serializer settings
  • Compatible with Laravel 12.x and PHP 8.2+
Frequently asked questions about Laravel Datatables Fractal
What is yajra/laravel-datatables-fractal used for?
It is a plugin for yajra/laravel-datatables that transforms server-side DataTables responses using league/fractal transformers. Instead of hand-writing JSON for each endpoint, you define a transformer once and reuse it across list screens. It is a thin adapter for the row-serialization step, not a standalone data layer.
How do I install yajra/laravel-datatables-fractal?
Install it with Composer using composer require yajra/laravel-datatables-fractal:^12.0. The package requires PHP 8.2 or higher, Laravel 12.x, and an existing yajra/laravel-datatables installation. Service provider registration and config publishing are optional on modern Laravel versions.
Does this package work without yajra/laravel-datatables installed?
No. The plugin does nothing on its own because it plugs into the DataTables server-side response pipeline. You must already have yajra/laravel-datatables deployed and be using server-side DataTables processing. Confirm your existing DataTables footprint and major version before adopting it.
Which PHP and Laravel versions does laravel-datatables-fractal support?
The current line requires PHP 8.2 or higher and Laravel 12.x. The package tracks Laravel majors, with matching releases for Laravel 9.x, 10.x, 11.x, 12.x, and 13.x. Older Laravel 8.x and below use the 1.x package line.
How do I use a Fractal transformer with a DataTables query?
Build your DataTables query as usual, then route the response through the plugin so each row is passed to your Fractal transformer. Define the transformer once and reuse it across endpoints that share the same entity or response shape. This keeps API output consistent without writing custom JSON per screen.
Do I need to register the FractalServiceProvider or publish config in Laravel 12?
Service provider registration is optional on Laravel 5.5 and later due to package auto-discovery. Config and assets are also optional and can be published with php artisan vendor:publish --tag=datatables-fractal --force. Most projects can install the package and start using transformers without extra setup.
Can I include relationships or computed fields with Fractal transformers in DataTables?
Yes, transformer includes and computed fields follow normal Fractal behavior, so relationships and derived values can be exposed consistently. You should still set conventions for included relations and computed-field policy across teams. Without standards, the second and third screens tend to fork instead of reuse the first transformer.
Is laravel-datatables-fractal safe to use in production?
It is a narrow, MIT-licensed utility with a very small adoption profile and effectively a single maintainer, so treat it as a replaceable utility rather than critical infrastructure. The realistic risk is abandonment, not a security catastrophe. Vendoring or forking is a cheap contingency, and you should document that option if you have single-maintainer dependency governance.
How does laravel-datatables-fractal compare to Laravel API Resources?
Fractal transformers are an alternative serialization convention, not a replacement for API Resources, GraphQL, or client-side DataTables. Choose this package when you have already standardized on server-side DataTables and want transformer-shaped responses. It does not add capabilities like real-time updates or exports.
What should I watch out for when upgrading Laravel or testing these DataTables endpoints?
Package releases track Laravel majors, so every Laravel upgrade carries a corresponding DataTables-Fractal bump. Put it on your upgrade checklist and add contract tests around transformer output so response changes are caught early. Because documentation and the ecosystem are small, expect troubleshooting to rely on reading the source.
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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core