2lenet/dashboard2-bundle
A Symfony bundle for building customizable dashboards with widgets. Generate widgets via maker, control visibility with roles, configure caching and Twig templates, and store widget data with Doctrine migrations. Includes setup and troubleshooting recipes.
AbstractWidget with render(), getName(), and supports() methods.config fields.make:widget, make:workflow-widget) accelerate development.StaticWidgetProviderInterface, useful for read-only or marketing dashboards.supports() method) integrates with Symfony’s security system ($this->security->getUser()).security, form, twig). In Laravel, this would need Symfony’s HTTP Kernel or a bridge (e.g., spatie/laravel-symfony-support).routes.yaml; Laravel’s routes/web.php would need adaptation (e.g., via RouteServiceProvider).widgets table (migration provided). Laravel’s migration system can handle this, but Doctrine ORM (Symfony’s default) would need Elquent integration or a hybrid approach.| Risk Area | Description | Mitigation Strategy |
|---|---|---|
| Symfony Dependency | Laravel’s ecosystem is optimized for Laravel, not Symfony bundles. | Use Symfony’s HTTP Kernel in a subdirectory or adopt a micro-framework (e.g., Symfony Standalone). |
| ORM Incompatibility | Doctrine ORM vs. Eloquent. Widgets may rely on Doctrine features (e.g., QueryBuilder). |
Abstract data access layer (DAL) or use Eloquent Doctrine Bridge (e.g., laravel-doctrine/orm). |
| Caching Complexity | Widget caching uses Symfony’s cache system. Laravel’s cache drivers (Redis, file) may not align. | Implement a cache adapter (e.g., symfony/cache with Laravel’s cache store). |
| Static Dashboard | Requires custom StaticWidgetProvider. Laravel’s service providers would need to register the provider and tag widgets (Symfony’s autoconfiguration feature). |
Use Laravel’s tagging system (e.g., bindTagged()) or manually register widgets in a service provider. |
| Chartjs Dependency | Relies on Symfony UX Chartjs. Laravel’s charting libraries (e.g., chartjs/chart.js) may not be directly compatible. | Use Symfony UX Chartjs in a standalone mode or replace with a Laravel-compatible charting library (e.g., laravel-chartjs). |
| Performance | Widget caching (5-minute TTL) may not suit real-time dashboards. | Override getCacheTimeout() or disable caching (return 0) for dynamic widgets. |
| Component | Laravel Native Alternative | Symfony Bundle Alternative | Integration Strategy |
|---|---|---|---|
| Routing | routes/web.php |
routes.yaml |
Use Symfony’s UrlGenerator in Laravel routes or create a custom route loader to merge Symfony routes into Laravel’s router. |
| Dependency Injection | Laravel’s container (app() helper) |
Symfony’s autowiring | Use Symfony’s ContainerInterface in Laravel or adopt a hybrid container (e.g., symfony/dependency-injection). |
| Templating | Blade (@include, @component) |
Twig ({% extends %}, {{ }}) |
Option 1: Use Twig in Laravel via twig/bridge. Option 2: Render Twig templates via PHP strings in Blade (less ideal). |
| ORM | Eloquent | Doctrine ORM | Option 1: Use Eloquent Doctrine Bridge (e.g., laravel-doctrine/orm). Option 2: Abstract queries into a repository layer compatible with both. |
| Forms | Laravel Collective Forms | Symfony Forms | Use Symfony Forms in Laravel via Symfony’s FormFactory or replace with Laravel Collective Forms (manual mapping required). |
| Security | Laravel’s Auth (Auth::user()) |
Symfony Security ($this->security->getUser()) |
Use Symfony’s Security component in Laravel or create a facade to bridge Laravel’s Auth with Symfony’s security context. |
| Caching | Laravel Cache (Cache::get()) |
Symfony Cache ($cache->get()) |
Use Symfony’s CacheInterface with Laravel’s cache drivers via an adapter (e.g., symfony/cache-adapter). |
| Charting | chartjs/chart.js | Symfony UX Chartjs | Option 1: Replace Symfony UX Chartjs with Laravel Chartjs (e.g., artesaos/laravel-chartjs). Option 2: Use Symfony UX Chartjs in a standalone JS context. |
| Asset Management | Laravel Mix/Vite | Symfony Encore | Use Laravel Mix/Vite for assets and Symfony Encore only for widget-specific JS/CSS (if needed). |
How can I help you explore Laravel packages today?