Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Datatables Bundle

Datatables Bundle Laravel Package

omines/datatables-bundle

View on GitHub
Deep Wiki
Context7

DataTables bundle for Symfony

Frequently asked questions about Datatables Bundle
Can I use this bundle in a Laravel project instead of yajra/laravel-datatables?
No, this bundle is specifically designed for Symfony 6.4+ and won’t work directly in Laravel. Laravel developers should use packages like yajra/laravel-datatables or adapt similar concepts with Laravel’s query builder. The architecture is tightly coupled to Symfony’s ecosystem.
How do I install and configure the bundle for Doctrine ORM?
Run `composer require omines/datatables-bundle` and enable the bundle in `config/bundles.php`. Configure the Doctrine adapter in your controller or service by injecting `DataTables` and specifying the entity class. The bundle auto-detects Doctrine entities and handles server-side processing. Full setup instructions are in the [official documentation](https://omines.github.io/datatables-bundle/).
Does this bundle support server-side processing for large datasets (e.g., 100K+ rows)?
Yes, the bundle is optimized for server-side processing, which is critical for large datasets. It leverages Doctrine’s query builder for efficient pagination, sorting, and filtering. For MongoDB or Elastica, ensure proper indexing to avoid performance bottlenecks. Test with realistic data volumes before production deployment.
How do I add custom columns or modify the table output in Twig?
Use the `Column` class to define custom columns in your controller or service. For Twig templates, extend the base template (`datatables/_table.html.twig`) or override specific blocks. The bundle supports column callbacks, rendering logic, and even custom Twig functions for dynamic content. Example configurations are in the [documentation](https://omines.github.io/datatables-bundle/).
What’s the best way to handle AJAX CSRF protection for DataTables callbacks?
Symfony’s built-in CSRF protection works out of the box for DataTables AJAX calls. Ensure your controller actions are annotated with `@Route` and use Symfony’s `csrf_token` helper in your Twig templates or JavaScript. For API-heavy applications, consider using Symfony’s `Voters` or `Firewalls` to secure routes without CSRF for trusted clients.
Can I use this bundle with MongoDB or Elastica without Doctrine ORM?
Yes, the bundle includes built-in adapters for MongoDB (via `mongodb/mongo-php-library`) and Elastica. Configure the adapter in your service or controller by specifying the connection and collection/index. For FOSElasticaBundle, ensure your Elasticsearch configuration aligns with the bundle’s requirements. Custom adapters are also possible for other data sources.
How do I persist DataTables state (e.g., sorting, pagination) across sessions?
Use the `persist_state` option in your DataTables configuration to store state in fragments, sessions, or cookies. For scalability, configure Symfony’s session handler (e.g., Redis) to avoid memory issues. The bundle supports all standard Symfony session storage mechanisms. Example configurations are provided in the [documentation](https://omines.github.io/datatables-bundle/).
Is there a way to integrate this bundle with modern frontend frameworks like React or Vue?
The bundle relies on jQuery and DataTables JS, but you can wrap it in a modern framework by using Alpine.js, Stimulus, or a custom wrapper. For SPAs, consider server-side rendering (SSR) with Symfony and hydrating DataTables on the client. Alternatively, use DataTables’ ES modules (e.g., `datatables.net-dt`) to avoid jQuery dependencies entirely.
What are the risks of using jQuery and DataTables JS in a new Symfony project?
jQuery and DataTables JS may introduce version conflicts or bloat if not managed carefully. Use Symfony’s AssetMapper or Webpack Encore to bundle dependencies efficiently. If jQuery isn’t already in your project, evaluate the migration effort—some projects opt for lighter alternatives like Tabulator.js or AG Grid for modern frontends.
How do I create a custom adapter for a non-Doctrine data source (e.g., a custom API or GraphQL)?
Implement the `DataSourceInterface` and define how to fetch, sort, and paginate data. The bundle’s modular design makes this straightforward, but you’ll need to handle query translation (e.g., converting DataTables parameters to your API’s format). Start with the existing adapters as a reference and extend the `AbstractAdapter` class for shared logic.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky