- 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.