PHPackages                             ebrahemalwish/laravel-multi-guard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ebrahemalwish/laravel-multi-guard

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ebrahemalwish/laravel-multi-guard
=================================

A Laravel package to scaffold multiple authentication guards (web, JWT, Passport) with migrations, models, middleware, controllers, routes, seeders, and views.

v1.0.1(2mo ago)23↑900%MITPHPPHP ^8.1

Since Mar 11Pushed 2mo agoCompare

[ Source](https://github.com/ebrahem-eng/laravel-multi-guard)[ Packagist](https://packagist.org/packages/ebrahemalwish/laravel-multi-guard)[ RSS](/packages/ebrahemalwish-laravel-multi-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Multi Guard 🛡️
======================

[](#laravel-multi-guard-️)

> A Laravel package that scaffolds **multiple authentication guards** in seconds — complete with migrations, models, middleware, controllers, routes, seeders, and a beautiful Aurora UI.

---

What does this package do?
--------------------------

[](#what-does-this-package-do)

Run one command and answer a few questions. The package will automatically generate **every file** needed for each authentication guard you define — whether it's a classic web session guard, a JWT API guard, or a Passport API guard.

No more copy-pasting boilerplate across `admin`, `vendor`, `driver`, `customer`, and however many other guard types your project needs.

---

Requirements
------------

[](#requirements)

DependencyVersionPHP^8.1Laravel^10.0 | ^11.0 | ^12.0tymon/jwt-auth *(optional, for JWT guards)*^2.0laravel/passport *(optional, for Passport guards)*^12.0---

Installation
------------

[](#installation)

```
composer require ebrahemalwish/laravel-multi-guard
```

Laravel's auto-discovery will register the service provider automatically.

---

Usage
-----

[](#usage)

### Build guards

[](#build-guards)

```
php artisan multi-guard:build
```

The command will ask:

1. **How many guards do you want?** — enter a number (anything else is rejected with an error).
2. **Guard name** — e.g. `admin`, `vendor`, `customer`.
3. **Guard type** — `web` or `api`.
4. *(API only)* **API driver** — `jwt` or `passport`.

Repeat steps 2–4 for each guard, then sit back.

---

### Remove guards

[](#remove-guards)

```
php artisan multi-guard:remove
```

Enter comma-separated guard names, or type `all` to remove every guard that was generated.
You will be asked to confirm before any files are deleted.

---

What gets generated per guard?
------------------------------

[](#what-gets-generated-per-guard)

### For every guard (web + api)

[](#for-every-guard-web--api)

FileLocationMigration`database/migrations/YYYY_MM_DD_HHmmss_create_{guard}s_table.php`Model`app/Models/{Guard}.php`Middleware`app/Http/Middleware/{Guard}AuthMiddleware.php`API Resource`app/Http/Resources/{Guard}Resource.php`Seeder`database/seeders/{Guard}Seeder.php`Route file`routes/{guard}.php`### Web guards only

[](#web-guards-only)

FileLocationController`app/Http/Controllers/{Guard}/{Guard}Controller.php`Auth Controller`app/Http/Controllers/{Guard}/Auth/AuthController.php`Dashboard view`resources/views/{guard}/dashboard.blade.php`Login view`resources/views/{guard}/Auth/login.blade.php`### API guards only

[](#api-guards-only)

FileLocationAuth Controller (JWT/Passport)`app/Http/Controllers/{Guard}/v1/Auth/AuthController.php`---

What gets modified in your project?
-----------------------------------

[](#what-gets-modified-in-your-project)

FileWhat changes`config/auth.php`Guard entry + provider entry added`bootstrap/app.php` *(Laravel 11+)*Route groups + middleware aliases added via `->withRouting()` and `->withMiddleware()``app/Http/Kernel.php` *(Laravel 10)*`$middlewareAliases` entries added`app/Providers/RouteServiceProvider.php` *(Laravel 10)*Route groups registered in `boot()``database/seeders/DatabaseSeeder.php``$this->call(GuardSeeder::class)` added`public/css/style.css`Aurora UI stylesheet published *(skipped if already exists)*---

Generated file details
----------------------

[](#generated-file-details)

### Migration columns

[](#migration-columns)

Every guard table gets these columns:

```
id, name, email (unique), email_verified_at, password,
gender (enum: male/female), status (enum: active/inactive),
age, birthday, phone, img, last_login_at, last_login_ip,
remember_token, timestamps

```

### Model

[](#model)

Extends `Authenticatable`. Includes `HasFactory`, `Notifiable`, the correct `$guard` name, full `$fillable`, `$hidden`, and a `casts()` method.

### Middleware

[](#middleware)

**Web guard middleware** redirects to the guard's login page when unauthenticated or inactive.
**API guard middleware** returns JSON `401` responses.

The alias is always `{guard}.auth` (e.g. `admin.auth`).

### Web routes

[](#web-routes)

```
GET  /{guard}/login           → login page
POST /{guard}/login/check     → authenticate
POST /{guard}/logout          → logout        [protected]
GET  /{guard}/dashboard       → dashboard     [protected]

```

### API routes

[](#api-routes)

```
POST /api/v1/auth/login-email → authenticate → returns token + resource

```

### API Resource

[](#api-resource)

Returns all model fields as JSON — useful in login responses and anywhere you need to return a guard's data cleanly.

### Seeder

[](#seeder)

Creates a default user for the guard:

```
email:    {guard}@example.com
password: Password@123
status:   active

```

### Views (web guards only)

[](#views-web-guards-only)

A production-ready **Aurora UI** kit is published:

- `public/css/style.css` — dark-glass design system (auto-skip if already present).
- `dashboard.blade.php` — full dashboard with sidebar, topbar, stat cards, chart, activity feed, table, and progress bars.
- `login.blade.php` — login card with email/password validation, error flash, and show/hide password toggle.

---

After running `multi-guard:build`
---------------------------------

[](#after-running-multi-guardbuild)

```
php artisan migrate
php artisan db:seed
```

Then visit `/{guardName}/login` in your browser (web guards) or POST to `/api/v1/auth/login-email` (API guards).

---

Middleware alias reference
--------------------------

[](#middleware-alias-reference)

Guard nameAlias`admin``admin.auth``vendor``vendor.auth``customer``customer.auth`*(etc.)*`{guard}.auth`Use in routes like:

```
Route::group(['middleware' => ['admin.auth']], function () {
    // protected routes
});
```

---

Auth config drivers
-------------------

[](#auth-config-drivers)

Guard typeDriverWeb`session`API (JWT)`jwt`API (Passport)`passport`---

License
-------

[](#license)

MIT — free to use in any project, commercial or otherwise.

---

Contributing
------------

[](#contributing)

Pull requests welcome. Please open an issue first to discuss what you'd like to change.

---

Credits
-------

[](#credits)

Built with ❤️ by **Ebrahem Alwish**. Aurora UI design system included.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance87

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

62d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b96c02af2fa2f620243face20b2960b3e073f42ba37d08e4f6d05d1f8cd3624?d=identicon)[ebrahemk968](/maintainers/ebrahemk968)

---

Tags

jwtlaravelauthpassportguardmulti-guard

### Embed Badge

![Health badge](/badges/ebrahemalwish-laravel-multi-guard/health.svg)

```
[![Health](https://phpackages.com/badges/ebrahemalwish-laravel-multi-guard/health.svg)](https://phpackages.com/packages/ebrahemalwish-laravel-multi-guard)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[corbosman/laravel-passport-claims

Add claims to Laravel Passport JWT Tokens

88655.9k](/packages/corbosman-laravel-passport-claims)[benbjurstrom/cognito-jwt-guard

A laravel auth guard for JSON Web Tokens issued by Amazon AWS Cognito

1113.1k](/packages/benbjurstrom-cognito-jwt-guard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
