This repository is a fork of https://github.com/stwe/DatatablesBundle.
- PHP 8.1 or higher
- Doctrine ORM 3.2 or higher. ORM 3.0 and 3.1 are not supported: the generated query uses
the DQL
PARTIALkeyword, which was removed in ORM 3.0 and only reintroduced in ORM 3.2. - Symfony 6.4, 7 or 8
- Run
composer require sst/datatablesbundle - Copy the following into
config/routes/sg_datatables_bundle.yaml
sg_datatables_bundle:
resource: "@SgDatatablesBundle/Controller/"type: attributeprefix: /sgThe bundle's controller uses native PHP attributes (#[Route]), so the loader type is
attribute. Earlier versions of this README said type: annotation; that value still works on
Symfony 6.4 but triggers a deprecation there, and Symfony 7 dropped it. If you are upgrading
and see
Make sure there is a loader supporting the "annotation" type.
then this is the line to change.
Since ORM 3, PARTIAL is only supported for array hydration. The query built by
DatatableQueryBuilder therefore combines partial <alias>.{...} with
Query::HYDRATE_ARRAY and can never be object-hydrated - doing so throws a
Doctrine\ORM\Internal\Hydration\HydrationException.
This matters if you take the query builder out of the bundle and run the query yourself:
// fine - this is what the bundle does$query = $datatableQueryBuilder->getBuiltQb()->getQuery();
$rows = $query->getArrayResult();
// throws HydrationException$rows = $datatableQueryBuilder->getBuiltQb()->getQuery()->getResult();