PHP code example of vaibhavpandeyvpz / doctrine-datatables

1. Go to this page and download the library: Download vaibhavpandeyvpz/doctrine-datatables library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vaibhavpandeyvpz / doctrine-datatables example snippets




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());



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());