chweb / multi-auth
Laravel 12 Multi-Auth Package for PHP 8.4
Requires
- php: ^8.4
- illuminate/console: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
- symfony/process: ^6.0|^7.0
This package is auto-updated.
Last update: 2026-03-26 08:43:26 UTC
README
A modern, easy-to-use multi-authentication package for Laravel 12 with full Laravel Breeze integration. Supports Blade, React (Inertia), and Vue (Inertia) stacks.
✨ Features
- 🚀 Quick Setup - One command to scaffold complete authentication
- 🎨 Multi-Stack Support - Blade, React, and Vue with Inertia.js
- 🔍 Auto-Detection - Automatically detects and adapts to your stack
- 🔧 Breeze Integration - Seamlessly works with Laravel Breeze
- 📦 Complete Scaffolding - Models, migrations, controllers, routes, views, and config
- 🔐 Password Reset - Built-in secure password reset functionality
- 🎯 Guard-Specific - Separate authentication for different user types
- 🎛️ Feature Toggling - Enable/Disable Login, Registration, or Password Reset per guard
- 💎 Modern UI - Premium glassmorphism designs with Tailwind CSS
- 💡 User-Friendly - Interactive prompts and helpful messages
📋 Requirements
- PHP ^8.4
- Laravel ^11.0 | ^12.0
- Composer
📦 Installation
Install the package via Composer:
composer require chweb/multi-auth:^1.0@beta
🚀 Quick Start
Create a new authentication guard (e.g., for admins):
php artisan multi-auth:install admin
That's it! The package will:
- Check if Laravel Breeze is installed (and offer to install it if not)
- Detect your current stack (Blade, React, or Vue)
- Generate all necessary files for your new guard
- Provide instructions for final configuration
📖 Usage
Basic Command
php artisan multi-auth:install {guard-name}
Examples
Create an admin authentication:
php artisan multi-auth:install admin
Create a manager authentication:
php artisan multi-auth:install manager
Overwrite existing files:
php artisan multi-auth:install admin --force
🎯 What Gets Generated?
For All Stacks
- Model:
app/Models/{Guard}.php - Migration:
database/migrations/{timestamp}_create_{guards}_table.php - Controllers:
LoginController.phpDashboardController.phpPasswordResetLinkController.phpNewPasswordController.php
- Routes:
routes/{guard}.php - Config:
config/multi-auth.php
Stack-Specific Files
Blade Stack:
resources/views/{guard}/login.blade.phpresources/views/{guard}/forgot-password.blade.phpresources/views/{guard}/reset-password.blade.phpresources/views/{guard}/dashboard.blade.phpresources/views/{guard}/layouts/app.blade.phpresources/views/{guard}/layouts/navigation.blade.php
React Stack (Inertia):
resources/js/Pages/{Guard}/Login.jsxresources/js/Pages/{Guard}/ForgotPassword.jsxresources/js/Pages/{Guard}/ResetPassword.jsxresources/js/Pages/{Guard}/Dashboard.jsx
Vue Stack (Inertia):
resources/js/Pages/{Guard}/Login.vueresources/js/Pages/{Guard}/ForgotPassword.vueresources/js/Pages/{Guard}/ResetPassword.vueresources/js/Pages/{Guard}/Dashboard.vue
⚙️ Configuration
1. Feature Toggling (config/multi-auth.php)
You can enable or disable specific features (Login, Password Reset, etc.) for each guard in config/multi-auth.php. This file is generated automatically.
'guards' => [ 'admin' => [ 'login' => true, 'password_reset' => true, 'register' => false, // Feature coming soon ], ],
2. Auth Configuration (config/auth.php)
After running the install command, update your config/auth.php:
'guards' => [ 'admin' => [ 'driver' => 'session', 'provider' => 'admins', ], ], 'providers' => [ 'admins' => [ 'driver' => 'eloquent', 'model' => App\Models\Admin::class, ], ], 'passwords' => [ 'admins' => [ 'provider' => 'admins', 'table' => 'password_reset_tokens', 'expire' => 60, 'throttle' => 60, ], ],
Register your routes in bootstrap/app.php:
->withRouting( web: __DIR__.'/../routes/web.php', commands: __DIR__.'/../routes/console.php', health: '/up', then: function () { Route::middleware('web') ->group(base_path('routes/admin.php')); }, )
Note: If you are using Laravel 10 or older, register the route in
app/Providers/RouteServiceProvider.php.
⚡ Frontend Setup
After installing the package, ensure you install dependencies and build assets:
npm install npm run dev
Run the migration:
php artisan migrate
🛣️ Routes
For a guard named admin, the following routes are created:
| Method | URI | Name | Description |
|---|---|---|---|
| GET | /admin/login |
admin.login |
Show login form |
| POST | /admin/login |
admin.login |
Process login |
| POST | /admin/logout |
admin.logout |
Logout |
| GET | /admin/forgot-password |
admin.password.request |
Show forgot password form |
| POST | /admin/forgot-password |
admin.password.email |
Send reset link |
| GET | /admin/reset-password/{token} |
admin.password.reset |
Show reset password form |
| POST | /admin/reset-password |
admin.password.store |
Reset password |
| GET | /admin/dashboard |
admin.dashboard |
Dashboard (protected) |
🔐 Authentication
The generated controllers use guard-specific authentication:
// Login Auth::guard('admin')->attempt($credentials); // Check authentication Auth::guard('admin')->check(); // Get authenticated user Auth::guard('admin')->user(); // Logout Auth::guard('admin')->logout();
🎨 Breeze Integration
Automatic Detection
The package automatically detects if Laravel Breeze is installed. If not, you'll be prompted to install it with your preferred stack.
Stack Detection
The package detects your stack by checking package.json:
- React: Looks for
@inertiajs/react - Vue: Looks for
@inertiajs/vue3 - Blade: Default if no Inertia dependencies found
Manual Breeze Installation
If you prefer to install Breeze manually:
composer require laravel/breeze --dev
php artisan breeze:install blade # or react, vue
Then run the multi-auth command:
php artisan multi-auth:install admin
📚 Documentation
For detailed documentation, see:
🔄 Version
Current version: 1.1.0
Access programmatically:
use Chweb\MultiAuth\MultiAuthServiceProvider; echo MultiAuthServiceProvider::VERSION; // 1.0.2
📝 Changelog
See CHANGELOG.md for details on updates and changes.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This package is open-sourced software licensed under the MIT license.
👨💻 Author
Harshit Chavda
- Email: harshit.chavda@icloud.com
🙏 Credits
This package is inspired by the deprecated hesto/multi-auth package, rebuilt for modern Laravel with Breeze integration.
Disclaimer: This package is built on Laravel Breeze and inspired by the hesto/multi-auth concept. It is provided without any claim to original copyrights.
⚠️ Support
For issues, questions, or feature requests, please open an issue on GitHub.
Made with ❤️ for the Laravel community