PHPackages                             intracto/datatables-backend - 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. intracto/datatables-backend

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

intracto/datatables-backend
===========================

Library to handle AJAX calls for datatables.net

v2.0.1(3y ago)47.2k—0%4MITPHPPHP &gt;=8.1

Since Aug 11Pushed 3y ago28 watchersCompare

[ Source](https://github.com/Intracto/datatables-backend)[ Packagist](https://packagist.org/packages/intracto/datatables-backend)[ Docs](https://github.com/Intracto/datatables-backend)[ RSS](/packages/intracto-datatables-backend/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)DependenciesVersions (12)Used By (0)

Intracto DataTables library
===========================

[](#intracto-datatables-library)

Handle AJAX requests for Datatables.net.

Install
-------

[](#install)

```
composer require intracto/datatables-backend

or

"intracto/datatables-backend" : "dev-master"

```

### Columns

[](#columns)

Container class to hold `Column` objects. This is used to get the field for sorting.

### Column

[](#column)

Hold data about a column, can be used for the frontend to render `` and let DataTables known which fields are sortable and searchable (via javascript).

### DataProvider

[](#dataprovider)

Get the data to show in the datatable. Requires `Parameters`, `DataTablesRepository`, `ColumnTransformer`.

### Parameters

[](#parameters)

Container class to hold data from the datatables AJAX request.

### DataTablesRepositoryInterface

[](#datatablesrepositoryinterface)

Defines query functions needed to fetch the data.

### DataTablesRepositoryTrait

[](#datatablesrepositorytrait)

An implementation of `DataTablesRepositoryInterface` with general queries. Only available for Doctrine ODM for now.

### ColumnTransformerInterface

[](#columntransformerinterface)

Transform data fetched from the `Repository` to format needed for the datatables. The order of the fields is important here.

---

Example
-------

[](#example)

### Columns

[](#columns-1)

```
class AddressListColumns extends Columns
{
    public function __construct()
    {
        parent::__construct(
            array(
                // In order of the tables headers
                new Column('city', 'city', true, true),
                new Column('zip', 'zip', false, false),
                new Column('street', 'street', false, false),
                new Column('actions', 'actions', false, false),
            )
        );
    }
}

```

### Transformer

[](#transformer)

```
class AddressListColumnTransformer implements ColumnTransformerInterface
{
    /**
     * @var EngineInterface
     */
    private $renderEngine;

    /**
     * AddressListColumnTransformer constructor
     *
     * @param EngineInterface $renderEngine
     */
    public function __construct(EngineInterface $renderEngine)
    {
        $this->renderEngine = $renderEngine;
    }

    /**
     * @param array $data
     *
     * @return array
     */
    public function transform(array $data)
    {
        $columns = array();

        foreach ($data as $address) {
            /**
             * @var Address $address
             */
            $columns[] = array(
                $address->getCity()
                $address->getZip()
                $address->getStreet()
                $this->renderEngine->render('Address/_list.actions.html.twig', array('address' => $address)),
            );
        }

        return $columns;
    }
}

```

### Repository

[](#repository)

```
class AddressRepository extends DocumentRepository implements DataTablesRepositoryInterface
{
    use DataTablesRepositoryTrait;
}

```

### Controller

[](#controller)

```
public function listAction()
{
    $columns = new AddressListColumns();

    return array(
        'columns' => $columns,
    );
}

public function ajaxListAction(Request $request)
{
    $parameters = Parameters::fromParameterBag($request->query, new AddressListColumns());

    $data = $this->dataTablesDataProvider->getData(
        $parameters,
        $addressRepository,
        $addressListColumnTransformer
    );

    return new JsonResponse($data);
}

```

---

### Frontend

[](#frontend)

#### External JS

[](#external-js)

Include `ajax-datatables.js` after loading the official datatables.js plug-in

#### Twig html

[](#twig-html)

Make sure the table has the "ajaxdatatable" class Loop all the columns in the table head

```

            {% for column in columns %}
                {{ ("translatable.prefix." ~ column.name)|trans }}
            {% endfor %}

```

Default sorting needed? Add the class `default_sort` and `asc`|`desc` to the `` to the correct column

```

    ...

```

#### Twig JS

[](#twig-js)

On the twig page where the ajax datatable must be loaded, place following script block

The `filters` are optional, here you can pass searchable/filterable fields

```

    $(document).ready(function(){

        {# define the ajax call path #}
        var ajaxCallPath = "{{ path("path_to_your_ajax_call") }}";

        {# define which columns are orderable #}
        var sortable = [
            {% for column in columns %}
                {%- if column.orderable -%}
                    {{ 'null' }}
                {%- else -%}
                    {{ '{ "orderable": false }'}}
                {%- endif -%}
                {{ ',' }}
            {% endfor %}
        ];

        {# page load filter fields, do not add .val() since we need the reference #}
        var filters = {
            'name': $("#js-filter-naam"),
            'address.city': $("#js-filter-city")
        };

        {# on page load, init the datatable #}
        ajaxDatatable(ajaxCallPath, sortable, filters, stateSaveAffix);

        {# on submit, change, whenever you want #}
        $(document).on("click", "#js-filter-submit", function(){
            {# no need to pass the parameters again #}
            ajaxDatatable();
        });
    });

```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

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 ~299 days

Recently: every ~282 days

Total

9

Last Release

1170d ago

Major Versions

v0.1.3 → v1.0.02020-01-31

v1.2.0 → v2.0.02022-06-13

PHP version history (2 changes)v0.1.1PHP &gt;=5.4

v2.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/57f44cb52273c29c230dbd1e9ef080402d53eaebcdd1fafbf5c6b75527b40199?d=identicon)[tvlooy](/maintainers/tvlooy)

![](https://www.gravatar.com/avatar/80809e7caf8341b1bac3d759e2b159a38b9bdab2deee5b0d4d66de6c83b992d1?d=identicon)[IntractoSupport](/maintainers/IntractoSupport)

---

Top Contributors

[![wimme002](https://avatars.githubusercontent.com/u/975457?v=4)](https://github.com/wimme002 "wimme002 (10 commits)")[![vermeirentony](https://avatars.githubusercontent.com/u/9335910?v=4)](https://github.com/vermeirentony "vermeirentony (2 commits)")[![tonyvermeiren](https://avatars.githubusercontent.com/u/227131594?v=4)](https://github.com/tonyvermeiren "tonyvermeiren (1 commits)")

---

Tags

symfonydatatablesajax

### Embed Badge

![Health badge](/badges/intracto-datatables-backend/health.svg)

```
[![Health](https://phpackages.com/badges/intracto-datatables-backend/health.svg)](https://phpackages.com/packages/intracto-datatables-backend)
```

###  Alternatives

[maba/webpack-bundle

Bundle to Integrate Webpack to Symfony

123268.2k4](/packages/maba-webpack-bundle)[lampjunkie/php-datatables

PHP Library for (http://www.datatables.net)

5817.4k](/packages/lampjunkie-php-datatables)[openskill/datatable

This is a Laravel 5 package for the server and client side of DataTables (http://datatables.net/)

5511.2k1](/packages/openskill-datatable)

PHPackages © 2026

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