Installation
How to install and configure UX DataTables
Requirements
- PHP 8.3+
- 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 watchVerify Installation
The @pentiminax/ux-datatables/datatable Stimulus controller is now available in your application.
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
table_attributes:
class: 'table'
extensions:
buttons: [csv, excel, pdf, print]
select:
style: single
Configuration Options
| Option | Description |
|---|---|
| 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). 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 |