Helper library to implement Doctrine powered server-side processing for jquery-datatables with joins, search, filtering and ordering.
composer require vaibhavpandeyvpz/doctrine-datatables
Usage with doctrine/dbal:
<?php
use Doctrine\DataTables;
$connection = /** instanceof Doctrine\DBAL\Connection */;
$datatables = (new DataTables\Builder())
->withIndexColumn('id')
->withQueryBuilder(
$connection->createQueryBuilder()
->select('*')
->from('users')
)
->withRequestParams($_GET);
echo json_encode($datatables->getResponse());
Usage with doctrine/orm:
<?php
use Doctrine\DataTables;
$em = /** instanceof Doctrine\ORM\EntityManager */;
$datatables = (new DataTables\Builder())
->withColumnAliases([
'id' => 'u.id',
'name' => 'u.name',
'email' => 'u.email',
'createdAt' => 'u.createdAt',
'updatedAt' => 'u.updatedAt',
])
->withIndexColumn('u.id')
->withQueryBuilder(
$em->createQueryBuilder()
->select('u')
->from(User::class, 'u'))
->withRequestParams($_GET);
echo json_encode($datatables->getResponse());
See LICENSE.md file.