- How do I install 2lenet/dashboard2-bundle in a Laravel app?
- Install it with Composer using composer require 2lenet/dashboard2-bundle. Because it is a Symfony bundle, Laravel requires additional Symfony component bridges, route adaptation, and a widgets table migration. You will also need to register routes and run migrations for the widgets table.
- Is 2lenet/dashboard2-bundle compatible with Laravel?
- It is not natively Laravel-compatible because it is a Symfony bundle that relies on Twig, Symfony security, Doctrine ORM, and Symfony's cache system. You can evaluate a hybrid setup using Symfony components alongside Laravel, for example with a bridge such as spatie/laravel-symfony-support. Expect custom work for routing, dependency injection, database access, and templating.
- How do I create a custom widget in 2lenet/dashboard2-bundle?
- Use the maker command php bin/console make:widget to generate a widget class and Twig template. Alternatively, extend AbstractWidget and implement methods such as render, which is mandatory and returns the widget content. You can also define getName for the title and supports for role-based visibility.
- How does widget caching work and can I disable it?
- Widgets use caching with a 5-minute TTL by default to improve dashboard performance. You can override getCacheTimeout or return 0 to disable caching for dynamic widgets that need real-time data. In a Laravel context, you may need a cache adapter because the bundle uses Symfony's cache system.
- How do I control which users see a dashboard widget?
- Implement the supports method on your widget to define role-based visibility. If supports returns false, users cannot see or add that widget. You can access the logged-in user inside the widget using $this->security->getUser().
- Why is my widget not showing up in the dashboard?
- Check the widget roles first, because supports may be hiding it from the current user. Inspect the network tab for a 500 error from the widget and try clearing the cache. Also run bin/console asset:install and confirm the dashboard routes were added correctly.
- Can I use Blade instead of Twig with this dashboard bundle?
- The bundle is built around Twig templating and provides a base template at @LleDashboard/widget/base_widget.html.twig. Using Blade in Laravel would require a Twig bridge or inline Twig rendering, which may be less performant. Evaluate whether Twig is acceptable before adopting the bundle in a Laravel project.
- What database schema does 2lenet/dashboard2-bundle require?
- The bundle requires a widgets table and provides a migration workflow using make:migration and doctrine:migrations:migrate. In Laravel, you can adapt this to Laravel's migration system, but the bundle's data layer is designed around Doctrine ORM rather than Eloquent. You may need an Eloquent Doctrine bridge or a custom data access layer.
- Does 2lenet/dashboard2-bundle support static dashboards?
- Yes, it supports static dashboards through StaticWidgetProviderInterface for predefined layouts. This is useful for read-only or marketing dashboards where users should not rearrange widgets. In Laravel, you would need to register the provider and tag widgets through a service provider or manual binding.
- What are alternatives to 2lenet/dashboard2-bundle for Laravel dashboards?
- Laravel teams often evaluate native dashboard tools such as Filament, Laravel Nova, or Livewire-based dashboards instead of a Symfony bundle. These alternatives avoid Twig, Doctrine, and Symfony container compatibility concerns. Consider 2lenet/dashboard2-bundle only if you are comfortable bridging Symfony components into Laravel.