esclaudio / datatables

Datatables API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple server side processing for datatables

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Installation

You can install the package via composer:

composer require esclaudio/datatables

Usage

use Esclaudio\Datatables\Datatables;
use Esclaudio\Datatables\Options;
use Esclaudio\Datatables\Database\Connection;

$connection = new Connection(new \PDO(...));
$options = new Options($_GET);

header('Content-Type: application/json');
echo (new Datatables($connection, $options))
    ->from('posts')
    ->join('users', 'users.id', '=', 'posts.created_by')
    ->select([
        'posts.id as id',
        'posts.title as title',
        'users.name as creator',
    ])
    ->toJson(); // {"draw": 1, "recordsTotal": 1, "recordsFiltered": 1, "data": {...}}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

About

Datatables API

License:MIT License


Languages

Language:PHP 100.0%