ram-electronic / datatable-bundle
Reusable DataTable and Pagination bundle for Symfony applications
Package info
github.com/ram-electronic/datatable-bundle
Type:symfony-bundle
pkg:composer/ram-electronic/datatable-bundle
Requires
- php: >=8.4
- doctrine/doctrine-bundle: ^2.11
- doctrine/orm: ^3.0
- symfony/form: ^7.0
- symfony/framework-bundle: ^7.0
- symfony/options-resolver: ^7.0
- symfony/routing: ^7.0
- symfony/security-csrf: ^7.0
- symfony/translation: ^7.0
- symfony/translation-contracts: ^3.0
- symfony/ux-live-component: ^2.0
- symfony/ux-twig-component: ^2.0
- symfony/validator: ^7.0
Requires (Dev)
- phpunit/phpunit: ^12.5
This package is auto-updated.
Last update: 2026-08-17 20:24:43 UTC
README
Reusable DataTable and Pagination bundle for Symfony applications: filterable, sortable, paginated table views built on Doctrine ORM, Symfony Forms, and Symfony UX Live Components.
Requirements
- PHP 8.4+
- Symfony 7.0+ (
framework-bundle,form,routing,security-csrf,translation,validator) - Symfony UX
live-componentandtwig-component2.0+ - Doctrine
orm3.0+ anddoctrine-bundle2.11+
Installation
composer require ram-electronic/datatable-bundle
If your app doesn't use Symfony Flex, register the bundle manually in
config/bundles.php:
return [ // ... RamElectronic\DataTableBundle\DataTableBundle::class => ['all' => true], ];
Twig components
The bundle registers its Twig components under the RamElectronic\DataTableBundle\Presentation\Twig\Components
namespace, with one exception: Table, Pagination, and the Table\Body,
Table\Cell, Table\Head, Table\Header, and Table\Row components are
not auto-registered (see config/services.php). Those names collide with
anonymous Twig components most consuming apps already define for their own
markup, so you're expected to supply your own Table/Row/Cell/etc. and
compose them with the parts the bundle does register:
FilterForm/FilterCondition— Live Components backing the filter UIPaginationControl— pagination controlsTable:ActionsCell,Table:DataCell,Table:HeadRow,Table:SortableHeader
See templates/components/ for the reference markup these components render.
Usage
- Define your filterable columns with an
Application\ReadModel\FilterFieldRegistrysubclass built fromColumndefinitions. - Extend
Infrastructure\Repository\DoctrineTableReadModelRepositoryfor your read-model entity's repository — it provides filtering, sorting, and pagination against a DoctrineQueryBuildergiven a field-to-column mapping. - In your controller, build a
TableCriteriafrom request/form data viaPresentation\Service\TableCriteriaBuilder(which composesFilterCollectionBuilder), and pass it to your repository. - Render results with
PaginationControland the bundle'sTable:*components inside your own table markup.
Testing
composer install vendor/bin/phpunit
License
MIT, see LICENSE.