PHPackages                             ropendev/datatablesphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ropendev/datatablesphp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ropendev/datatablesphp
======================

PHP DataTables wrapper class for DataTables.js (Html and/or Javascript generation, Server-Side SQL) .

0.0.95(11y ago)286.7k20[1 issues](https://github.com/RobinDev/DataTablesPHP/issues)MITPHPPHP &gt;=5.3.0CI failing

Since Nov 6Pushed 6y ago8 watchersCompare

[ Source](https://github.com/RobinDev/DataTablesPHP)[ Packagist](https://packagist.org/packages/ropendev/datatablesphp)[ Docs](http://www.robin-d.fr/DataTablesPHP/)[ RSS](/packages/ropendev-datatablesphp/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

[DataTablesPHP : PHP class to easily use DataTables.js](http://www.robin-d.fr/DataTablesPHP/)
=============================================================================================

[](#datatablesphp--php-class-to-easily-use-datatablesjs)

[![Build Status](https://camo.githubusercontent.com/6299030527e645bee2f9f65a504433b43c2eaccb3b04e3c23bafd61fd68ec6e5/68747470733a2f2f7472617669732d63692e6f72672f526f62696e4465762f446174615461626c65735048502e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/RobinDev/DataTablesPHP)[![Total Downloads](https://camo.githubusercontent.com/d88b734fd403cccc7c65e6657909ea23ad51905ff4292cfb0c17dbaa060312a3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f70656e6465762f646174617461626c65737068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ropendev/datatablesphp)

\##Table of contents

- [Description](#description)
    - [Features](#features)
- [Installation](#installation)
    - [Packagist](https://packagist.org/packages/ropendev/datatablesphp)
- [Example](#example)
- [Documentation](#documentation)
- [License](#license)
- [Todo](#todo)

\##Description

DataTablesPHP generates easily your DataTable Html or Javascript... with Server-Side or not. It enhances the filters's utilisation adding individual column filtering (with or without server-side).

**Compatible with the last version of DataTables (1.10.x).**

\###Features

- Generate html table (complex header)
- Generate the Javascript related (Data can be set in the initial parameters or load via Ajax or Server-Sive)
- Custom search column by column and complex search to optimize SQL queries
- Analyze Server-Side Request and Generate SQL queries
    - Can handle complex query (join)
    - Can handle Optimize Query to search value (not only Like %, you can parameter to use =,&lt;,&gt;,&lt;=,&gt;=,BETWEEN...)
- Using all this features in the same time permits to easily handle a dataTable with PHP

Server-side part inspired from [Allan Jardine's Class SSP](https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/ssp.class.php). Improve in order to don't trust user input, add the join possibilities and more...

\##Installation

You can clone this git, download the class or use Composer :

```
composer require ropendev/datatablesphp
```

\##Example

See in the `examples` folder.

\##Documentation

```
DataTable::instance('id')
    ->setJsInitParam($key, $value)           // http://datatables.net/reference/option/
    ->setJsInitParams($params)               // To set all params in one time
    ->setDom($dom)                           // Alias for setJsInitParameter('dom', $dom)
    ->setColumn($params, $show = true)       // Add a column and there options to the table:
                                             // - Initialization Javascript Options (see the doc : DataTables.net > Refererences > Column)
                                             //  - PHP Options (parent for complex header, sFilter, sql_table, sqlFilter... see l.169)
                                             // if($show) will be printed in the table else will only be load via ajax
    ->setColumns($columns)                   // Add columns
    ->setServerSide($ajax)                   // http://datatables.net/reference/option/ajax
    ->setAjax($ajax)                         // Alias for setJsInitParameter('ajax', $ajax)
    ->setFilters($ajax)                      // Set permanent filters for sql queries (where)
    ->setData($data)                         // Permit to set the data in the DataTables Javascript Initialization.
    ->setHeader($bool)                       // To generate thead when you will call getHtml
    ->setFooter($bool)                       // To generate tfoot with th empty when you will call getHtml.
                                             // ... automatically called if you have set individual column filters

DataTable::instance('id')->getJavascript();  // Return javascript string. It is not embeding JS Files from DataTables.js... only it activation
                                            // and individual column filtering stuff

DataTable::instance('id')->getHtml([array('class'=>'my_table_class', 'data-nuclear'=>'bomb')]);        // Return html table in a string

/*** Server-Side Functions ***/
# You can't use server side options if you didn't set Columns

DataTable::instance('id')
    ->setFrom($table)                                                                                                 // Name of the table to query
    ->setJoin('table2', array('table'=>'column', 'table2'=>'column2') [, $join = 'LEFT JOIN', $duplicate = false])    // Table to join
    ->setPdoLink($pdoLink)                                                                                            // Add PHP PDO class link
    ->setCounterActive(false)  // Disabled counters (permits to gain in performanche, think to change your infoFiltered)

DataTable::instance('id')->exec($_REQUEST[, $csv = false]);  // Output the json results
                                                             //or export to csv format (use setInitFilter before if you use Individual column Filters)
DataTable::instance('id')->sendFatal($error);                // Output an error
```

A php array for a column can contain :

- Properties for Initialization Javascript (see `self::$columnParams` or )
- `parent` (`=>$title`) : To have a complex header with a colspan... Set the same $title to put multiple column under the same th
- `sFilter` (`=>array`) : for the column filtering options (see `self::$columFilteringParams`)
- SQL params (`sql_name` and `sql_table`) : if there is different from data or default table set with setFrom
- `alias` : sql alias (not required)
- `formatter` (`=>function($columnValue,$rowValues,$columnParams)`) : if you want to print your data with a special format, set a function In a Server-Side Request, if you don't want select a SQL column, just don't set `sql_name` or `data` properties (but set a `formatter` function to print something !).

\##License

MIT (see the `LICENSE` file for details)

\##Todo It will come soon :

- AutoGenerate select's options if there is data (l.469)
- Example with export function

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Total

6

Last Release

4149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/afce4cf517928a50560237f1410d5957271fd808671b2216687ecf1422adaee0?d=identicon)[Robin D.](/maintainers/Robin%20D.)

---

Top Contributors

[![lvillain](https://avatars.githubusercontent.com/u/5121552?v=4)](https://github.com/lvillain "lvillain (1 commits)")[![MrAtiebatie](https://avatars.githubusercontent.com/u/2266552?v=4)](https://github.com/MrAtiebatie "MrAtiebatie (1 commits)")[![PauloPereira87](https://avatars.githubusercontent.com/u/9914912?v=4)](https://github.com/PauloPereira87 "PauloPereira87 (1 commits)")

---

Tags

datatablesframework agnostichtml-tablejQuery TableDataTables.js

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ropendev-datatablesphp/health.svg)

```
[![Health](https://phpackages.com/badges/ropendev-datatablesphp/health.svg)](https://phpackages.com/packages/ropendev-datatablesphp)
```

###  Alternatives

[yajra/laravel-datatables-oracle

jQuery DataTables API for Laravel

4.9k33.8M339](/packages/yajra-laravel-datatables-oracle)[wenzhixin/bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)

11.8k283.4k1](/packages/wenzhixin-bootstrap-table)[rappasoft/laravel-livewire-tables

A dynamic table component for Laravel Livewire

2.0k2.7M31](/packages/rappasoft-laravel-livewire-tables)[yajra/laravel-datatables-html

Laravel DataTables HTML builder plugin

2899.6M48](/packages/yajra-laravel-datatables-html)[yajra/laravel-datatables-buttons

Laravel DataTables Buttons Plugin.

2629.1M54](/packages/yajra-laravel-datatables-buttons)[yajra/laravel-datatables-editor

Laravel DataTables Editor plugin for Laravel 5.5+.

1186.1M2](/packages/yajra-laravel-datatables-editor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
