Open-source project
yajra/laravel-datatables avatar
yajra/laravel-datatables

Laravel DataTables: server-side processing for the jQuery grid, via Eloquent

jQuery DataTables API for Laravel

4,872 stars853 forksPHPMIT

At a glance

What is it?
Yajra's Laravel DataTables is an MIT-licensed PHP package handling the server-side works of the DataTables jQuery plugin through the AJAX option, backed by Eloquent ORM, the Fluent Query Builder or Collections. Version 13 matches Laravel 13, the facade accepts eloquent, query, collection and make entry points, and ten years of Laravel version compatibility are documented in one table.
Who is it for?
Use Laravel DataTables when a Laravel application serves DataTables grids that must paginate, sort and search on the server, since the package translates the plugin's AJAX protocol into Eloquent or query builder calls rather than shipping whole tables to the browser. Evaluate whether a jQuery-era grid belongs in the frontend at all before adopting.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 15 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The server-side half of a client-side grid

The package handles the server-side works of the DataTables jQuery plugin via its AJAX option, using Eloquent ORM, Fluent Query Builder or Collection as the data source, which places it precisely in a two-part architecture. DataTables in the browser sends requests describing the page, sort column, direction and global search, and the server must translate those into filtered, ordered, paginated queries and answer in the plugin's JSON format. Doing that by hand for every grid is boilerplate, and this package is the translation layer, accepting a Laravel query object and returning the JSON. The documentation site is yajrabox.com, the package on Packagist is yajra/laravel-datatables-oracle, and the project has run since the Laravel 4.2 era per its own compatibility table. The choice among the three engines is itself an architecture decision, Eloquent carries relations and accessors into the grid, the query builder keeps the SQL lean for wide tables, and collections move filtering into PHP where data has already been assembled from non-database sources, and because all three return the same JSON contract, a grid's data source can migrate between them without touching the frontend.

Three entry points, one facade

The usage example is six lines that define the API's surface:

php
use Yajra\DataTables\Facades\DataTables;

return DataTables::eloquent(User::query())->toJson();
return DataTables::query(DB::table('users'))->toJson();
return DataTables::collection(User::all())->toJson();

return DataTables::make(User::query())->toJson();
return DataTables::make(DB::table('users'))->toJson();
return DataTables::make(User::all())->toJson();

The three named methods match the three data sources, Eloquent for relations and scopes, the query builder for lean SQL, and collections for data already in memory, while make infers the engine from the argument type. Every path ends in toJson, the JSON that the browser-side DataTables instance consumes, so a controller route is the entire server-side integration. The facade pattern matters in Laravel's architecture, the alias resolves through the service container, so tests can swap the underlying engine without touching controllers, and the six-line example doubles as the shape of a real controller method, request in, query composed, toJson out.

A compatibility table back to Laravel 4.2

The Laravel version compatibility table is the package's history in eighteen rows, Laravel 4.2 with package 3.x, the Laravel 5.0 through 5.3 era on 6.x, 5.4 through 5.7 on 7.x and 8.x, 5.8 through Laravel 8 on 9.x, Laravel 9 and 10 on 10.x, and from Laravel 11 onward the numbers align, 11.x with 11.x, 12.x with 12.x, 13.x with 13.x. The convergence tells the maintenance story, the package once chased Laravel's breaking changes across multiple majors per release, and now the majors move in step. The requirement list beside it is short and current, PHP 8.3 or later, the Laravel framework, and DataTables itself on the frontend side. The alignment era also simplifies upgrades, since Laravel 11 the rule is same-number to same-number, so planning a framework upgrade now implies the matching package major, and the UPGRADE.md file at the repository root carries the per-major migration notes.

Two install options, and the meta package

Installation offers two shapes. Option one installs all DataTables libraries, the meta package pulling the family:

bash
composer require yajra/laravel-datatables:"^13"

option two installs only this library:

bash
composer require yajra/laravel-datatables-oracle:"^13"

The service provider and facade registration is optional on Laravel 5.5 and later because of automatic discovery, with the manual config/app.php entries shown for the older flow, DataTablesServiceProvider and the DataTables facade alias. Publishing configuration is optional too, php artisan vendor:publish with the provider named, and the closing sentence, start building out some awesome DataTables, hands off to the quick starter documentation. The two-option split answers a real question, whether the buttons, exports and HTML add-ons of the family are wanted or the core engine alone.

Debugging mode embeds your queries

The debugging note doubles as a security reminder. Setting APP_DEBUG to true makes the package include the queries and inputs used when processing the table, the visibility needed while developing a grid, and the important notice attached states the production side plainly, ensure the APP_DEBUG config is set to false when your app is in production. Debug output on a data endpoint is not just noise, it exposes the query shape and the raw inputs of every table request, and the package opts into that behavior only under the debug flag rather than shipping it always on. For teams running the package behind monitoring, the same debugging payload is also the reason the flag matters, leaked query text on a public endpoint maps the schema for anyone who asks, and the package leaves the choice to the environment variable Laravel already governs.

The php artisan serve warning

A dedicated section warns against one development setup, avoid using php artisan serve when developing the package, with the failure modes named, Laravel randomly returns a redirect and 401 Unauthorized if the route requires authentication, and a 404 NotFoundHttpException on valid routes. The advice is to use Homestead or Valet when working with the package, the links pointing at the Laravel 5.4 era documentation, a section that has survived in the README because the symptom keeps puzzling developers whose DataTables requests fail only under the built-in server. For a package whose whole job is AJAX requests hitting authenticated routes, the difference between PHP's built-in server and a real SAPI is visible exactly here. The 401 symptom deserves its explanation, an authenticated AJAX endpoint responds differently from a page load, and when the built-in server mishandles the request chain the grid receives a redirect instead of JSON, a failure that looks like a broken route rather than a server quirk, which is why the section has persisted in the documentation.

Code hygiene and the credits chain

The repository shows a PHP project with modern tooling, phpstan with a neon config for static analysis running beside continuous integration workflows, pint for code style, rector for automated refactoring, phpunit for tests, and a releaserc for automated versioning. The credits name Arjay Angeles as the author, credit the bllim/laravel4-datatables-package as the lineage the package grew from, and thank the DataTables project itself plus Blackfire.io with a free open-source license among the sponsors. Security issues route to a personal email rather than the issue tracker. The current release train is v13, 13.2.0 and 13.3.0 in August 2026 and 13.3.1 on 2026-09-15, the same day as the last push, matching Laravel 13. A context7.json file at the repository root registers the package with documentation-lookup tooling, the small addition that puts the package's docs in front of coding assistants, consistent with a project that has outlived several generations of developer tooling already.

Editorial conclusion

Use Laravel DataTables when a Laravel application serves DataTables grids that must paginate, sort and search on the server, since the package translates the plugin's AJAX protocol into Eloquent or query builder calls rather than shipping whole tables to the browser. Evaluate whether a jQuery-era grid belongs in the frontend at all before adopting. Before installing, match the package major to your Laravel version with the compatibility table, require the meta package or the oracle core accordingly, and set APP_DEBUG to false in production, since debugging mode embeds the queries and inputs used into the response.

Frequently asked questions

How can I use DataTables in Laravel?

Install yajra/laravel-datatables and have controller routes return DataTables::eloquent, query or collection calls converted with toJson, which handles the server-side processing the DataTables jQuery plugin requests through its AJAX option, including pagination, sorting and search against Eloquent or the query builder.

What is Laravel and why is it used?

Laravel is the PHP framework this package extends, and it is used here because DataTables' server-side processing needs routing, request handling and the Eloquent ORM or query builder to translate table requests into database queries, all of which Laravel provides as the foundation the package builds on.

Which Laravel versions does Laravel DataTables support?

The compatibility table runs from Laravel 4.2 with package 3.x through the current pairing of Laravel 13 with package 13.x, with the version numbers aligned one-to-one from Laravel 11 onward. The package requires PHP 8.3 or later on current releases.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. yajra/laravel-datatables on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/yajra-laravel-datatables.svg)](https://hysenlabs.com/projects/yajra-laravel-datatables)