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 3w 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 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

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

3434d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8615201?v=4)[Nikita Stenin](/maintainers/stenin-nikita)[@stenin-nikita](https://github.com/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

[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5742.2M17](/packages/directorytree-ldaprecord-laravel)[franbarbalopez/mirror

Mirror is a Laravel package that handles user impersonation.

15520.3k](/packages/franbarbalopez-mirror)[hasinhayder/tyro

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

6753.6k5](/packages/hasinhayder-tyro)[offload-project/laravel-invite-only

A Laravel package for managing user invitations with polymorphic relationships, token-based access, scheduled reminders, and event-driven notifications.

727.7k2](/packages/offload-project-laravel-invite-only)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1542.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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