PHPackages                             chientd/laravel5\_multiauth - 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. chientd/laravel5\_multiauth

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

chientd/laravel5\_multiauth
===========================

Multiple auth driver for Laravel 5

v4.0.9(11y ago)010MITPHPPHP &gt;=5.4.0

Since Mar 28Pushed 9y ago1 watchersCompare

[ Source](https://github.com/tdchien/laravel5_multiauth)[ Packagist](https://packagist.org/packages/chientd/laravel5_multiauth)[ RSS](/packages/chientd-laravel5-multiauth/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (9)Used By (0)

IMPORTANT: Laravel 5.1 and onward
=================================

[](#important-laravel-51-and-onward)

Please head over to  as a replacement. kbwebs' fork is fully compatible with Laravel 5.1. Moving from my for to this should not need any changes in your code.

Laravel Multi Auth
------------------

[](#laravel-multi-auth)

- **Laravel**: 5
- **Author**: Ramon Ackermann
- **Author Homepage**:
- **Author**: Ollie Read
- **Author Homepage**:

For Laravel 4.2 version, see

---

**IMPORTANT: Laravel 5.1**Default AuthController with its traits

```
\Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers

```

more specifically

```
Illuminate\Foundation\Auth\AuthenticatesUsers::postLogin()

```

does not work! For the time being, you need to write your own Controller for this. I will work on it if I have time.

---

This package is not a replacement for laravels default Auth library, but instead something that sits between your code and the library.

Think of it as a factory class for Auth. Now, instead of having a single table/model to authenticate users against, you can now have multiple, and unlike the previous version of this package, you have access to all functions, and can even use a different driver for each user type.

On top of that, you can use multiple authentication types, simultaneously, so you can be logged in as a user, a master account and an admin, without conflicts!

Custom Auth Drivers
-------------------

[](#custom-auth-drivers)

At this current moment in time, custom Auth drivers written for the base Auth class will not work. I'm currently looking into this particular issue but for the meantime, you can work around this by changing your closure to return an instance of `Ollieread\Multiauth\Guard` instead of the default.

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

[](#installation)

Firstly you want to include this package in your composer.json file.

```
    "require": {
    		"sboo/multiauth" : "4.0.*"
    }
```

Now you'll want to update or install via composer.

```
composer update

```

Next you open up app/config/app.php and replace the 'Illuminate\\Auth\\AuthServiceProvider', with

```
    'Ollieread\Multiauth\MultiauthServiceProvider',
```

and 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider' with

```
	'Ollieread\Multiauth\Passwords\PasswordResetServiceProvider',
```

**NOTE** It is very important that you replace the default service providers.

Remove the original database migration for password\_resets.

\##Configuration##

is pretty easy too, take config/auth.php with its default values:

```
    return [

		'driver' => 'eloquent',

		'model' => 'App\User',

		'table' => 'users',

		'password' => [
        		'email' => 'emails.password',
        		'table' => 'password_resets',
        		'expire' => 60,
        	],

	];
```

Now remove the first three options (driver, model and table) and replace as follows:

```
    return [

		'multi'	=> [
			'admin' => [
				'driver' => 'eloquent',
				'model'	=> 'App\Admin',
			],
			'client' => [
				'driver' => 'database',
				'table' => 'clients',
				'email' => 'client.emails.password',
			]
		],

		'password' => [
        		'email' => 'emails.password',
        		'table' => 'password_resets',
        		'expire' => 60,
        	],

	];
```

This is an example configuration. Note that you will have to create Models and migrations for each type of user. Use App\\User.php and 2014\_10\_12\_000000\_create\_users\_table.php as an example.

If you wish to use a reminders email view per usertype, simply add an email option to the type, as shown in the above example.

To generate the reminders table you will need to run the following command.

```
php artisan multiauth:resets-table

```

Likewise, if you want to clear all reminders, you have to run the following command.

```
php artisan multiauth:clear-resets

```

You will also need to change the existing default Laravel 5 files to accommodate multiple auth and password types. Do as described in this gist:

Usage
-----

[](#usage)

Everything is done the exact same way as the original library, the one exception being that all method calls are prefixed with the key (account or user in the above examples) as a method itself.

```
    Auth::admin()->attempt(array(
    	'email'		=> $attributes['email'],
    	'password'	=> $attributes['password'],
    ));
    Auth::client()->attempt(array(
    	'email'		=> $attributes['email'],
    	'password'	=> $attributes['password'],
    ));
    Auth::admin()->check();
    Auth::client()->check();
```

I found that have to call the user() method on a user type called user() looked messy, so I have added in a nice get method to wrap around it.

```
	Auth::admin()->get();
```

In the instance where you have a user type that can impersonate another user type, example being an admin impersonating a user to recreate or check something, I added in an impersonate() method which simply wraps loginUsingId() on the request user type.

```
	Auth::admin()->impersonate('client', 1, true);
```

The first argument is the user type, the second is the id of said user, and the third is whether or not to remember the user, which will default to false, so can be left out more often than not.

And so on and so forth.

There we go, done! Enjoy yourselves.

Testing
-------

[](#testing)

Laravel integration/controller testing implements `$this->be($user)` to the base TestCase class. The implementation of #be() does not work correctly with Multiauth. To get around this, implement your own version of #be() as follows:

```
    public function authenticateAs($type, $user) {
      $this->app['auth']->$type()->setUser($user);
    }
```

### License

[](#license)

This package inherits the licensing of its parent framework, Laravel, and as such is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 58.2% of commits — single point of failure

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

Every ~13 days

Recently: every ~18 days

Total

7

Last Release

4032d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/67efca6a33c2a7d87493090902a3c09d80a39edd328fa2c994d904c2d1881d6b?d=identicon)[tdchien](/maintainers/tdchien)

---

Top Contributors

[![sboo](https://avatars.githubusercontent.com/u/3823326?v=4)](https://github.com/sboo "sboo (64 commits)")[![ollieread](https://avatars.githubusercontent.com/u/469515?v=4)](https://github.com/ollieread "ollieread (35 commits)")[![tdchien](https://avatars.githubusercontent.com/u/1614393?v=4)](https://github.com/tdchien "tdchien (4 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (3 commits)")[![tylerjohnst](https://avatars.githubusercontent.com/u/193916?v=4)](https://github.com/tylerjohnst "tylerjohnst (1 commits)")[![sahibalejandro](https://avatars.githubusercontent.com/u/985268?v=4)](https://github.com/sahibalejandro "sahibalejandro (1 commits)")[![shivergard](https://avatars.githubusercontent.com/u/1783151?v=4)](https://github.com/shivergard "shivergard (1 commits)")[![AliMalikTTX](https://avatars.githubusercontent.com/u/106072896?v=4)](https://github.com/AliMalikTTX "AliMalikTTX (1 commits)")

---

Tags

laravelauthlaravel 5multi

### Embed Badge

![Health badge](/badges/chientd-laravel5-multiauth/health.svg)

```
[![Health](https://phpackages.com/badges/chientd-laravel5-multiauth/health.svg)](https://phpackages.com/packages/chientd-laravel5-multiauth)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k2.1M163](/packages/laravel-ai)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9772.3M122](/packages/roots-acorn)[illuminate/queue

The Illuminate Queue package.

20432.2M1.5k](/packages/illuminate-queue)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M154](/packages/spatie-laravel-health)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6783.6k5](/packages/hasinhayder-tyro)

PHPackages © 2026

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