Installation
How to install and configure UX DataTables
Requirements
- PHP 8.2+
- Symfony 7.x or 8.x
- Symfony UX StimulusBundle 2.x or 3.x
Install the Bundle
Install via Composer
composer require pentiminax/ux-datatablesSymfony Flex will automatically enable the bundle.
Install Assets
AssetMapper
If you’re using AssetMapper (recommended for Symfony 7+), no extra work is needed. The bundle ships DataTables assets automatically.
Webpack Encore
If you’re using Webpack Encore, install the JavaScript dependencies and rebuild your assets:
npm install --force
npm run watchRegister the packages you use (recommended)
php bin/console ux-datatables:install --style=tailwind buttons responsive selectThe command registers only the DataTables packages your tables need, enables the
datatable_core controller, and sets package_loading: registered. See
Loading only the extensions you use. Skip this step to keep the 1.x
behavior, where the datatable controller bundles every package.
Verify Installation
The @pentiminax/ux-datatables/datatable Stimulus controller is available in your application,
or @pentiminax/ux-datatables/datatable_core if you ran the install command.
Bundle Configuration
Create a configuration file at config/packages/data_tables.yaml:
data_tables:
options:
language: en-GB
layout:
topStart: pageLength
topEnd: search
bottomStart: info
bottomEnd: paging
lengthMenu: [10, 25, 50]
pageLength: 10
package_loading: registered
table_attributes:
class: 'table'
extensions:
buttons: [csv, excel, pdf, print]
select:
style: single
Configuration Options
| Option | Description |
|---|---|
| package_loading | registered loads only the packages you register (see the install command). Leaving it unset is deprecated: the default becomes registered in 2.0 |
| language | Default language locale (e.g., en-GB, fr-FR) |
| layout | UI component positions (topStart, topEnd, bottomStart, bottomEnd) |
| lengthMenu | Available page length options |
| pageLength | Initial rows per page |
| table_attributes | Default attributes for the <table> element |
| extensions | Default extensions to enable |
Styling
The bundle ships with the DataTables default theme enabled. Check your assets/controllers.json:
{
"controllers": {
"@pentiminax/ux-datatables": {
"datatable": {
"enabled": true,
"autoimport": {
"datatables.net-dt/css/dataTables.dataTables.min.css": true,
"datatables.net-bs5/css/dataTables.bootstrap5.min.css": false
}
}
}
}
}
The bundle supports 4 CSS frameworks (Bootstrap 5, Bootstrap 4, Bootstrap 3, and the default DataTables theme). Bootstrap 3 and 4 are deprecated since 1.5 and removed in 2.0. The Stimulus controller automatically detects which stylesheet is loaded and applies the matching integration.
See Styling for the full setup guide.
Optional Dependencies
| Package | Feature |
|---|---|
symfony/form | Inline edit modal with auto-generated forms |
symfony/twig-bundle | Required for rendering edit modal templates |
api-platform/core | Auto-detect columns from API Platform metadata |
symfony/mercure-bundle | Real-time table updates via Mercure SSE |
symfony/maker-bundle | The make:datatable console command |