ladbu/laravel-ladwire-module
Modular Laravel package adding Ladwire (Livewire) components and Flux UI to fresh projects: install dashboard, user management (CRUD, search, pagination), and settings modules via artisan installer. PHP 8.2+, Laravel 11/12, Livewire 3/4.
Install the package in an existing Laravel project:
composer require ladbu/laravel-ladwire-module
Or for fresh projects, use the installer (if available in future versions).
Publish assets (if needed):
php artisan vendor:publish --provider="Ladbu\LaravelLadwireModule\LadbuServiceProvider" --tag="public"
Run migrations (if included in the package):
php artisan migrate
Register the module in your routes/web.php:
use Ladbu\LaravelLadwireModule\Http\Controllers\ModuleController;
Route::middleware(['auth'])->group(function () {
Route::get('/dashboard', [ModuleController::class, 'dashboard']);
Route::prefix('users')->group(function () {
Route::get('/', [ModuleController::class, 'users']);
Route::get('/create', [ModuleController::class, 'createUser']);
// ... other user routes
});
});
First use case: Access /dashboard to see the pre-built Ladwire-powered dashboard with Flux UI components.
resources/modules/ (if using v1.1.0+) for modular components.app/Http/Livewire/ for pre-built components (e.g., DashboardComponent, UserManagementComponent).php artisan vendor:publish --provider="Ladbu\LaravelLadwireModule\LadbuServiceProvider" --tag="config"
Then customize config/ladbu.php (e.g., module paths, default settings).--module flag (if supported in future versions) or manually enable/disable modules in config/ladbu.php:
'modules' => [
'dashboard' => true,
'user_management' => true,
'settings' => false, // Disable if unused
],
resources/modules/[module-name]/views/ or app/Http/Livewire/[Module]Component.php.Ladbu\LaravelLadwireModule\Livewire\BaseComponent for consistency:
namespace App\Http\Livewire;
use Ladbu\LaravelLadwireModule\Livewire\BaseComponent;
class CustomComponent extends BaseComponent {
public function mount() {
$this->title = 'Custom Title';
}
}
<x-flux.button type="primary" @click="openModal">
Action
</x-flux.button>
Or directly in Ladwire components:
public function render() {
return view('livewire.custom-component', [
'button' => '<x-flux.button>Click Me</x-flux.button>',
]);
}
resources/views/modules/dashboard/layout.blade.php to resources/views/modules/dashboard/ and modify.widgets array in config/ladbu.php:
'dashboard' => [
'widgets' => [
'recent-activity',
'custom-widget', // Your custom component
],
],
UserManagementComponent or extend it:
namespace App\Http\Livewire;
use Ladbu\LaravelLadwireModule\Livewire\UserManagementComponent as BaseUserComponent;
class UserManagementComponent extends BaseUserComponent {
protected $searchFields = ['name', 'email', 'role']; // Add custom fields
}
actions method in the component to include buttons like "Suspend" or "Audit":
public function actions() {
return array_merge(parent::actions(), [
'suspend' => 'Suspend',
]);
}
php artisan vendor:publish --provider="Ladbu\LaravelLadwireModule\LadbuServiceProvider" --tag="migrations"
Then create a new migration for your settings:
php artisan make:migration add_custom_settings_to_ladbu_settings_table
Settings facade to access/modify settings:
use Ladbu\LaravelLadwireModule\Facades\Settings;
public function saveCustomSetting() {
Settings::set('custom.key', $this->customValue);
}
auth) is applied to module routes. The package assumes Laravel Breeze/Jetstream auth by default.Gate::define('manage-users', function ($user) {
return $user->isAdmin();
});
Then add to your component:
public function canAccess() {
return Gate::allows('manage-users');
}
resources/lang/ to customize labels/buttons.$this->livewire(UserManagementComponent::class)
->assertSee('Users')
->call('search', 'test');
Version Mismatches:
composer.json for Laravel version constraints.$this->dispatch() vs. $this->emit()).Module Auto-Loading:
modules array in config/ladbu.php is correctly configured.resources/modules/ directory exists and is readable.Asset Conflicts:
@vite() or @stack directives carefully:
@vite(['resources/css/app.css', 'resources/js/app.js'])
@stack('scripts')
app.js/app.css files are included.Database Seeding:
DatabaseSeeder.php if not needed:
// database/seeders/DatabaseSeeder.php
Ladbu\LaravelLadwireModule\Database\Seeders\ModuleSeeder::run(); // Remove or comment out
Caching Issues:
php artisan view:clear
php artisan config:clear
php artisan route:clear
Ladwire Debugging:
config/livewire.php:
'log' => env('LIVEWIRE_LOG', true),
storage/logs/livewire.log for component lifecycle events.Flux UI Debugging:
npm run dev
Route Debugging:
php artisan route:list | grep ladbu
Component Lifecycle:
mount(), hydrate(), or updated() in your Ladwire components to log state changes:
public function mount() {
\Log::info('Component mounted', ['data' => $this->data]);
}
resources/modules/dashboard) and renaming it.How can I help you explore Laravel packages today?