PHPackages                             bizhub/impersonate - 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. bizhub/impersonate

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

bizhub/impersonate
==================

Impersonate a Laravel user

0.2(9y ago)25.5k↓100%1MITPHPPHP &gt;=5.6.4

Since Oct 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/bizhub/impersonate)[ Packagist](https://packagist.org/packages/bizhub/impersonate)[ Docs](http://bizhub.co.nz)[ RSS](/packages/bizhub-impersonate/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Impersonate a Laravel user
==========================

[](#impersonate-a-laravel-user)

Authenticate as another user while maintaining previous authentication.

This works by using Laravels `Auth::onceUsingId()` feature where you can authenticate as a user for that request only. A middleware will check if you're impersonating via a session variable and activate `Auth::onceUsingId()` for every request until you stop impersonating.

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

[](#installation)

### 1. Composer

[](#1-composer)

Execute the following command to get the latest version of the package:

```
composer require bizhub/impersonate

```

### 2. Laravel

[](#2-laravel)

Add `CheckIfImpersonating` middleware to `app\Http\Kernel.php`

```
  protected $middlewareGroups = [
      'web' => [
          // ...

          \Bizhub\Impersonate\Middleware\CheckIfImpersonating::class,
      ]
  ];
```

Add `CanImpersonate` trait to your `User` model

```
namespace App;

use Bizhub\Impersonate\Traits\CanImpersonate;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use CanImpersonate;

    // ...
}
```

Usage
-----

[](#usage)

```
// Retrieve your user model
$user = User::find(1);

// Start impersonating
$user->impersonate();

// Redirect/reload the page

// ...

// Stop impersonating
Auth::user()->stopImpersonating();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~152 days

Total

2

Last Release

3339d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0472059fd00a788248c7f2fb2d209121e0f29d3b4086614685c70ed13558c038?d=identicon)[Bizhub](/maintainers/Bizhub)

---

Top Contributors

[![bizhub](https://avatars.githubusercontent.com/u/1683367?v=4)](https://github.com/bizhub "bizhub (8 commits)")

---

Tags

authenticationbizhublaravellaravel-usersphplaravelimpersonatebizhub

### Embed Badge

![Health badge](/badges/bizhub-impersonate/health.svg)

```
[![Health](https://phpackages.com/badges/bizhub-impersonate/health.svg)](https://phpackages.com/packages/bizhub-impersonate)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[franbarbalopez/mirror

Mirror is a Laravel package that handles user impersonation.

1548.1k](/packages/franbarbalopez-mirror)[rickycezar/laravel-jwt-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

24117.6k](/packages/rickycezar-laravel-jwt-impersonate)[hapidjus/laravel-impersonate-ui

UI for 404labfr/laravel-impersonate

371.5k](/packages/hapidjus-laravel-impersonate-ui)[martbock/laravel-diceware

Diceware Passphrase Generator for Laravel

3264.7k](/packages/martbock-laravel-diceware)[ingria/laravel-x509-auth

Laravel 5 Client Certificate auth middleware

375.6k](/packages/ingria-laravel-x509-auth)

PHPackages © 2026

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