alp-develop/laravel-livewire-panel
Laravel admin panel framework powered by Livewire (v3/v4). Supports Bootstrap 4/5 and Tailwind CSS, with an installer for URL prefix, navigation mode, auth/gates, registration, optional CDN libs, and publishable views. Compatible with Laravel 10–13.
Installation:
composer require alp-develop/laravel-livewire-panel
php artisan panel:install
Follow prompts for URL prefix (e.g., admin), CSS theme (Bootstrap 5/Tailwind), and gate driver.
First Page: Create a Livewire component with the panel layout:
// app/Livewire/Dashboard.php
namespace App\Livewire;
use Livewire\Attributes\Layout;
use Livewire\Component;
#[Layout('panel::layouts.app')]
class Dashboard extends Component {
public function render() { return view('livewire.dashboard'); }
}
Route Registration:
// routes/web.php
use AlpDevelop\LivewirePanel\Http\Middleware\PanelAuthMiddleware;
Route::middleware(['web', PanelAuthMiddleware::class])
->prefix('admin')
->name('panel.admin.')
->group(function () {
Route::get('/', \App\Livewire\Dashboard::class)->name('home');
});
Access Panel:
Visit /admin/login to authenticate, then /admin to see your dashboard.
php artisan panel:list to inspect installed panels.config/panel.php for theme, guard, and CDN settings.Build a dashboard widget to display key metrics:
php artisan panel:make-widget stats-card --panel=admin
Edit the generated widget in app/Livewire/Admin/Widgets/StatsCard.php and add it to your dashboard:
// app/Livewire/Dashboard.php
public function render() {
return view('livewire.dashboard', [
'widgets' => [
StatsCard::class,
],
]);
}
Panel Configuration:
php artisan panel:install for interactive setup.config/panel.php:
'panels' => [
'admin' => [
'theme' => 'tailwind',
'guard' => 'web',
'prefix' => 'admin',
'cdn' => ['chartjs', 'sweetalert'],
],
],
Module-Based Development:
php artisan panel:make-module users --panel=admin
routes/panel.php:
Route::panel('admin')->group(function () {
Route::resource('users', \App\Livewire\Admin\UsersController::class);
});
Widget Integration:
#[Layout('panel::layouts.app')]
class Dashboard extends Component {
public function render() {
return view('livewire.dashboard', [
'widgets' => [
StatsCard::class,
RecentActivity::class,
],
]);
}
}
Navigation Management:
config/panel.php:
'navigation' => [
'admin' => [
'items' => [
['label' => 'Dashboard', 'route' => 'panel.admin.home'],
['label' => 'Users', 'route' => 'panel.admin.users.index'],
],
],
],
panel:make-module and register navigation in the module’s NavigationProvider.Authentication:
php artisan panel:make-component login --panel=admin
app/Providers/PanelServiceProvider.php:
Panel::extend('admin', function ($app) {
return new CustomPanelGate();
});
Livewire Components:
PanelComponent for shared functionality:
use AlpDevelop\LivewirePanel\Livewire\PanelComponent;
class Dashboard extends PanelComponent {
// Inherits panelId, panel(), and other helpers
}
#[Locked] to protect properties from Livewire’s reactivity:
#[Locked]
public string $panelId;
Theming:
resources/css/panel.css:
:root {
--panel-primary: #6366f1;
--panel-secondary: #10b981;
}
php artisan vendor:publish --tag=panel-themes
CDN Libraries:
config/panel.php:
'cdn' => [
'chartjs' => true,
'sweetalert' => false,
],
'cdn' => [
'custom' => [
'url' => 'https://cdn.example.com/script.js',
'integrity' => 'sha384-...',
],
],
Localization:
resources/lang/{locale}/panel.php:
return [
'dashboard' => [
'title' => 'Tablero',
'welcome' => 'Bienvenido',
],
];
{{ __('panel::dashboard.title') }}
Plugins:
php artisan panel:make-plugin notifications --panel=admin
public function registerNavigation() {
return [
'label' => 'Notifications',
'route' => 'panel.admin.notifications',
'icon' => 'bell',
];
}
Events:
PanelLoggedIn):
use AlpDevelop\LivewirePanel\Events\PanelLoggedIn;
PanelLoggedIn::listen(function ($event) {
\Log::info("User {$event->user->id} logged in to panel {$event->panelId}");
});
Testing:
PanelTestCase for panel-specific tests:
use AlpDevelop\LivewirePanel\Testing\PanelTestCase;
class DashboardTest extends PanelTestCase {
public function test_dashboard_loaded() {
$this->actingAs($user)
->panel('admin')
->get('/admin')
->assertOk();
}
}
Route Naming:
panel.{panelId}. (e.g., panel.admin.home).panel_route() helper or to_panel() macro:
Route::get('/', Dashboard::class)->name('panel.admin.home');
// or
Route::get('/', fn() => redirect()->to_panel('admin', 'home'));
Middleware Order:
PanelAuthMiddleware must be after web middleware in the stack.Route::middleware(['web', PanelAuthMiddleware::class])->group(...);
Livewire Hydration:
wire:ignore for static content or trigger updates via this->dispatch('refresh').CSS Conflicts:
.panel-custom-* or use !important sparingly. Inspect the generated CSS variables (e.g., --panel-primary).Dark Mode Persistence:
dark_mode_show_on_auth is true in config/panel.php and the dark-mode-toggle component is included in auth layouts.Navigation Search:
resources/lang/{locale}/panel.php under navigation.search.*.CDN Loading:
data-navigate-once attribute (handled automatically by the package) and verify CDN URLs in config/panel.php.Multi-Panel Conflicts:
--panel={id} in artisan commands and use Panel::for('admin')->... in code.Rate Limiting:
rate_limiting in config/panel.phpHow can I help you explore Laravel packages today?