PHPackages                             laracomponents/impersonation - 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. laracomponents/impersonation

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

laracomponents/impersonation
============================

Impersonating user for Laravel application.

v1.0.1(9y ago)21.0kMITPHPPHP &gt;=5.6.4

Since Jan 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/LaraComponents/impersonation)[ Packagist](https://packagist.org/packages/laracomponents/impersonation)[ Docs](https://github.com/LaraComponents/impersonation)[ RSS](/packages/laracomponents-impersonation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Impersonation for Laravel
=========================

[](#impersonation-for-laravel)

[![Build Status](https://camo.githubusercontent.com/273b7cb500be6d30e425b89fa2c1b6f24beae093c6f49504f5fe46a19dbdb82c/68747470733a2f2f7472617669732d63692e6f72672f4c617261436f6d706f6e656e74732f696d706572736f6e6174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/LaraComponents/impersonation)[![Latest Version](https://camo.githubusercontent.com/8fed91e909f4283b05b9687b65d8818bb6f01d9437d8f452b2020431f7447904/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4c617261436f6d706f6e656e74732f696d706572736f6e6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/LaraComponents/impersonation/releases)[![Quality Score](https://camo.githubusercontent.com/148b346ae282174bece5639c0f9a7a4a2cad6465e5a256f6711c4c7f1a79ccdf/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4c617261436f6d706f6e656e74732f696d706572736f6e6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/LaraComponents/impersonation)[![StyleCI](https://camo.githubusercontent.com/38c6345da41e905241a0de73c0ad9bdde2d09ae370d889ae45696c3b44dc95d2/68747470733a2f2f7374796c6563692e696f2f7265706f732f38303035353834362f736869656c64)](https://styleci.io/repos/80055846)[![Total Downloads](https://camo.githubusercontent.com/7efed43df407e925438680ddbd194baf4b44933c479a4351fddf1119c7b7f7b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4c617261436f6d706f6e656e74732f696d706572736f6e6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/LaraComponents/impersonation)[![Software License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/LaraComponents/impersonation/blob/master/LICENSE)

Introduction
------------

[](#introduction)

Impersonating user for Laravel application.

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

[](#installation)

You can install this package via composer using this command:

```
composer require laracomponents/impersonation
```

Next, you must add the Impersonable trait to the user model:

```
use LaraComponents\Impersonation\Traits\Impersonable;

class User
{
    use Impersonable;
    ...

    /**
     * Optional method
     * Default return the "impersonate_id"
    **/
    public function getImpersonatingKey()
    {
        return 'your session key here';
    }
}
```

Open App/Http/Kernal.php and add middleware to web middleware group:

```
    protected $middlewareGroups = [
        'web' => [
            ...
            \LaraComponents\Impersonation\Middleware\CheckForImpersonating::class,
        ],
        ...
    ];
```

And finally you should add a routes to routes/web.php. Example:

```
Route::get('users/{id}/impersonate', function ($id) {
    $user = \App\User::findOrFail($id);

    if(! $user->isImpersonating()) {
        $user->impersonate();
    }

    return redirect('/');
});

Route::get('users/unimpersonate', function () {
    $user = \Auth::user();

    if($user->isImpersonating()) {
        $user->unimpersonate();
    }

    return redirect('/');
});
```

Testing
-------

[](#testing)

You can run the tests with:

```
vendor/bin/phpunit
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/LaraComponents/impersonation/blob/master/LICENSE) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~0 days

Total

2

Last Release

3389d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef39b0b46136030c30f3fea73eb251ccaea7c439deda9064dad59572e78bb93f?d=identicon)[stenin-nikita](/maintainers/stenin-nikita)

---

Top Contributors

[![stenin-nikita](https://avatars.githubusercontent.com/u/8615201?v=4)](https://github.com/stenin-nikita "stenin-nikita (15 commits)")

---

Tags

laravelimpersonateUser management

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laracomponents-impersonation/health.svg)

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

###  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)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[franbarbalopez/mirror

Mirror is a Laravel package that handles user impersonation.

1548.1k](/packages/franbarbalopez-mirror)[tomatophp/filament-users

Manage your users with a highly customizable user resource for FilamentPHP with integration of filament-shield and filament-impersonate

90102.0k7](/packages/tomatophp-filament-users)[scaler-tech/laravel-saml2

SAML2 Service Provider integration for Laravel applications, based on OneLogin toolkit

2737.5k](/packages/scaler-tech-laravel-saml2)

PHPackages © 2026

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