laravel-datatables: one JSON endpoint for three data sources, and a debug flag to watch
jQuery DataTables API for Laravel
At a glance
- What is it?
- This package answers the DataTables AJAX request from Eloquent, the query builder or a plain collection, and its recent version numbers match Laravel's majors, while a single APP_DEBUG setting decides whether your SQL ships to the browser.
- Who is it for?
- Adopt laravel-datatables if you are building an admin table on Laravel and you want the DataTables plugin's paging, searching and ordering handled server side without writing the response shape by hand. Pick the package major the compatibility table pairs with your Laravel version, and read UPGRADE.md before crossing a major.
- 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 61 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 November 15, 2026, and from our analysis. They are not legal advice.
Star history
- yajra/laravel-datatables4,866 ★ · -6
| Repository | 2026-09-23 | 2026-11-15 |
|---|---|---|
| yajra/laravel-datatables | 4.9k | 4.9k |
-6 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
One facade, three data sources, and make() guesses for you
The whole integration is a route returning JSON. DataTables asks for a page of rows through its AJAX option, and this package builds the response from whichever data source you hand it:
use Yajra\DataTables\Facades\DataTables;
return DataTables::eloquent(User::query())->toJson();
return DataTables::query(DB::table('users'))->toJson();
return DataTables::collection(User::all())->toJson();Each of those three names the source explicitly: an Eloquent builder, a query builder table, or a collection you already have in memory. The same README then shows the shortcut, where make() takes the object and works out which of the three it is:
return DataTables::make(User::query())->toJson();
return DataTables::make(DB::table('users'))->toJson();
return DataTables::make(User::all())->toJson();So the choice is between a dispatcher and three explicit entry points. The explicit names document themselves at the call site; make() is shorter when your code already treats all three as interchangeable.
The package major follows the Laravel major
Version compatibility is a lookup table, and it is long enough that reading it is part of installing this package. The current end of it runs Laravel 9.x, 10.x, 11.x, 12.x and 13.x against package 10.x, 10.x, 11.x, 12.x and 13.x. Working back: 5.4.x pairs with 7.x or 8.x, 5.0.x through 5.3.x with 6.x, and Laravel 4.2.x with package 3.x.
The table shows the package major matching the framework major only from Laravel 10.x onward, so you pick your package version from your Laravel version rather than from its own history.
Two consequences. A Laravel 5.8 application is on package 9.x, which is four majors behind the current 13.x, so a fresh install of the newest package is not an option without moving the framework. And an old framework still has a documented answer here, which tells you the maintainer keeps the old mappings in the README rather than dropping them.
The requirements line is tighter: PHP >= 8.3, Laravel Framework, and DataTables itself.
Two composer packages, and the badges point at the smaller one
Installation comes in two flavours, and the difference is what else gets pulled in.
composer require yajra/laravel-datatables:"^13"That is option 1, described as installing all DataTables libraries. Option 2 installs only this library:
composer require yajra/laravel-datatables-oracle:"^13"The repository you are reading is the oracle package. The umbrella package is described as installing all DataTables libraries.
Worth noticing: the Packagist badges at the top of the README link to yajra/laravel-datatables-oracle, not to the umbrella package. So a reader who follows the badges lands on the smaller package, while the first install command on the page installs the larger one. Decide which you want before you run either.
APP_DEBUG=true puts your queries and inputs in the response
There is one switch worth reading twice. To enable debugging mode, set APP_DEBUG=true, and the package then includes the queries and inputs used when processing the table.
That is a genuinely useful feature when a table returns the wrong rows: you see the SQL that ran and the parameters the plugin sent, which is usually where the answer is. The same switch in production returns your SQL to anyone who asks for the table.
The README marks it important that APP_DEBUG is false when your app is in production, and that is the whole warning. There is no separate flag for the package, so the leak is governed by one framework environment value that plenty of projects leave on for convenience.
If your app sits behind a debug flag that someone might flip, the check belongs in deployment config rather than in a code review checklist.
php artisan serve returns random 401s, and the README says use Valet
There is a whole section of the README about a development server bug, and it is unusual enough to summarise. Please avoid php artisan serve when developing the package.
The known behaviour is that Laravel randomly returns a redirect and a 401 Unauthorized when the route requires authentication, and a 404 NotFoundHttpException on routes that are valid. The advice is to use Homestead or Valet instead.
The mechanism is never explained, so this reads as an inherited problem with the built-in server rather than something in the package, but the effect for a reader is the same: if you develop against php artisan serve and your table route needs authentication, you will lose time chasing a 401 that has nothing to do with your code.
Note the scope. The section is about developing the package itself. Nothing in it says the same bug applies to an application that consumes it, so treat it as a contributor warning rather than a production one.
config/app.php registration is optional from Laravel 5.5 on
On older setups the provider and the facade go in config/app.php by hand, which the README shows as one block with both arrays:
'providers' => [
...,
Yajra\DataTables\DataTablesServiceProvider::class,
]
'aliases' => [
...,
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
]That whole step is marked optional on Laravel 5.5 and above, because package discovery handles it from there. The alias name is what makes the facade read as DataTables rather than its full class name.
Configuration files are published with one Artisan command, also marked optional:
php artisan vendor:publish --provider="Yajra\DataTables\DataTablesServiceProvider"Both steps being optional means a default install is one composer command and nothing else, and the config file only exists for you if you ask for it.
PHPStan, PHPUnit, Pint and Rector, with releases cut automatically
The root of the repository is a PHP project with its quality tooling committed rather than left to each contributor.
phpstan.neon.dist holds static analysis configuration and phpunit.xml.dist the test suite. pint.json configures Pint, the Laravel code style fixer, and rector.php configures Rector for automated refactoring across versions.
Release handling is declared too: .releaserc.yml points at semantic-release, so a version bump follows a commit message rather than a manual tag. CHANGELOG.md records what came out, and UPGRADE.md is where breaking changes land. Since each Laravel version maps to a specific package major, UPGRADE.md is the file to read before you move a major version.
Two more root entries are worth naming: context7.json and CONDUCT.md, alongside .editorconfig, .gitattributes and .gitignore for the formatting of the repository itself.
Security reports go to an inbox, and the credits name a predecessor
Two closing sections say something about how the project is run.
Security issues are not for the issue tracker. The README asks that anything security related be emailed to [email protected] instead, which is the same address as the maintainer's, Arjay Angeles, listed first under Credits. A single inbox rather than a security policy file is a small thing, and it is the difference between a private report and a public one.
The credits also name bllim/laravel4-datatables-package before All Contributors, which identifies where this code came from: a Laravel 4 era package, still reflected in the compatibility table where 4.2.x pairs with package 3.x.
Two free licences keep the maintenance honest, and both are credited in the sponsors section: a free DataTables Editor licence from DataTables and a free open-source licence from Blackfire.io. The plugin and the profiler are the two tools you would otherwise pay for while building this.
Editorial conclusion
Adopt laravel-datatables if you are building an admin table on Laravel and you want the DataTables plugin's paging, searching and ordering handled server side without writing the response shape by hand. Pick the package major the compatibility table pairs with your Laravel version, and read UPGRADE.md before crossing a major. Two things to verify before you ship: that APP_DEBUG is false in production, since the package then returns the queries and inputs it used, and, if you develop the package itself, that you use Homestead or Valet rather than php artisan serve, which the README says breaks authenticated routes with random redirects, 401s and 404s.
Frequently asked questions
How can I use DataTables in Laravel?
Install the package with composer and return JSON from a route: DataTables::eloquent(User::query())->toJson(), or DataTables::query(DB::table('users'))->toJson(), or DataTables::collection(User::all())->toJson(). The package handles the server-side processing of the DataTables jQuery plugin through its AJAX option.
Which PHP and Laravel versions does laravel-datatables support?
PHP >= 8.3 and Laravel Framework. The compatibility table pairs Laravel 13.x with package 13.x, 12.x with 12.x, 11.x with 11.x, 9.x and 10.x with 10.x, and older Laravel releases with correspondingly older package majors, back to 4.2.x with 3.x.
Do I have to register the service provider for laravel-datatables?
Not on Laravel 5.5 and above, where the README marks the provider and facade registration optional because of package discovery. On older setups you add Yajra\DataTables\DataTablesServiceProvider::class and the DataTables alias to config/app.php, and config files come from php artisan vendor:publish --provider="Yajra\DataTables\DataTablesServiceProvider".
What does APP_DEBUG change in laravel-datatables?
With APP_DEBUG set to true the package includes the queries and inputs used when processing the table in its output, which is the fastest way to see why a table returned the wrong rows. The README marks it important that APP_DEBUG is false in production, since the same output carries your SQL.
Can I use php artisan serve when developing laravel-datatables?
The README advises against it, citing known bugs where Laravel randomly returns a redirect and a 401 Unauthorized on authenticated routes, and a 404 NotFoundHttpException on valid routes. It recommends Homestead or Valet instead, and notes the problem applies to developing the package.
Official sources
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.
[](https://hysenlabs.com/projects/yajra-laravel-datatables)Star history chart for your README
[](https://hysenlabs.com/projects/yajra-laravel-datatables)Was this useful?