PHPackages                             maurohmartinez/impersonate-users-backpack-laravel - 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. maurohmartinez/impersonate-users-backpack-laravel

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

maurohmartinez/impersonate-users-backpack-laravel
=================================================

A simple package that adds the impersonate operation for admins

1.1.7(7mo ago)1110.1k—1.9%4MITPHPPHP ^8.0

Since Jul 18Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/maurohmartinez/impersonate-users-backpack-laravel)[ Packagist](https://packagist.org/packages/maurohmartinez/impersonate-users-backpack-laravel)[ RSS](/packages/maurohmartinez-impersonate-users-backpack-laravel/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (24)Used By (0)

Impersonate users with Backpack for Laravel
===========================================

[](#impersonate-users-with-backpack-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d6daf208385a827abc00148a9b6a8d7d5944e9d0e9d252e842e53a7463d1db33/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6175726f686d617274696e657a2f696d706572736f6e6174652d75736572732d6261636b7061636b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maurohmartinez/impersonate-users-backpack-laravel)[![Total Downloads](https://camo.githubusercontent.com/24fafa562ac7fa91f6414eb08ac844afacd42639755585b2ac5fad7ae8971a82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6175726f686d617274696e657a2f696d706572736f6e6174652d75736572732d6261636b7061636b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maurohmartinez/impersonate-users-backpack-laravel)

This is a simple package to allow admins impersonate users.

[![alt text](https://github.com/maurohmartinez/impersonate-users-backpack-laravel/raw/main/src/sample.gif?raw=true)](https://github.com/maurohmartinez/impersonate-users-backpack-laravel/blob/main/src/sample.gif?raw=true)

Install
-------

[](#install)

In your terminal:

```
# install the package
composer require maurohmartinez/impersonate-users-backpack-laravel
```

In case you want/need to publish files to further customize this package:

```
php artisan vendor:publish --provider="MHMartinez\ImpersonateUser\app\Providers\ImpersonateUserServiceProvider"
```

Usage
-----

[](#usage)

1- Add in your `UserCrudController`.

```
use \MHMartinez\ImpersonateUser\app\Http\Controllers\Operations\ImpersonateUserOperation;
```

This will add a button for List and Show Operations to impersonate users.

2- Next step is to handle the logic to indicate which admins have permission to impersonate others, or can be impersonated. You just need to modify a bit your `User Model` to implement the interface `ImpersonateInterface` like this:

```
class User extends Authenticatable implements ImpersonateInterface
```

And then add the following two methods in your `User Model`:

```
/**
 * If you use Laravel-Backpack/PermissionManager you can do like this.
 * But you can also add any logic you need.
*/
public function canImpersonateOthers(): bool
{
    return $this->can('permission_to_impersonate'); // or replace "permission_to_impersonate" with the right permission
}
/**
 * Following the same example, you can deny admins from impersonating super admins.
*/
public function canBeImpersonated(): bool
{
    return !$this->hasRole('superadmin'); // or replace "superadmin" with the right permission
}
```

3- Now, you just need to add the button to exit impersonating (no worries, it will only show up when needed). For example, you can add the button in `topbar_right_content.blade.php` like this:

```
@include('impersonate_user::exit_impersonated')
```

4- Important — If you want to impersonate non-admin users you will need to skip the backpack middleware that determines if the user is admin. This is because this operation will need to allow your impersonated non-admin user to use a backpack route to log you back. How to do it?

- Publish the config file if you haven't done so (described here, above step one).

```
php artisan vendor:publish --provider="MHMartinez\ImpersonateUser\app\Providers\ImpersonateUserServiceProvider" --tag=config
```

- Add the middleware classname like it follows, and you will be good to go:

```
return [
    'session_key' => 'impersonating_user',
    'base_guard' => 'backpack',
    'admin_middleware' => Path\To\Middleware\IsAdmin::class,
    'skip_middlewares' => [],
];
```

This will allow this operation to skip that middleware when logging out impersonated non-admin users.

Credits
-------

[](#credits)

- [Mauro Martinez](https://inspiredpulse.com/) Developer
- [Cristian Tabacitu](https://tabacitu.ro/) For creating [Backpack for Laravel](https://backpackforlaravel.com/)!

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance65

Regular maintenance activity

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Recently: every ~75 days

Total

23

Last Release

211d ago

PHP version history (2 changes)v1.0.0PHP ^7.3|^8.0

1.1.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/21192abc454e8b809201f9150490b1b6f694cfdf3e6494d04fb915b9fb1e697d?d=identicon)[maurohmartinez](/maintainers/maurohmartinez)

---

Top Contributors

[![maurohmartinez](https://avatars.githubusercontent.com/u/33960976?v=4)](https://github.com/maurohmartinez "maurohmartinez (32 commits)")

---

Tags

backpacklaravellaravelbackpackforce ssl

### Embed Badge

![Health badge](/badges/maurohmartinez-impersonate-users-backpack-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/maurohmartinez-impersonate-users-backpack-laravel/health.svg)](https://phpackages.com/packages/maurohmartinez-impersonate-users-backpack-laravel)
```

###  Alternatives

[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

59437.0k9](/packages/jeremy379-laravel-openid-connect)[backpack/theme-tabler

UI for Backpack v6 that uses Tabler and Bootstrap v5.

37627.2k](/packages/backpack-theme-tabler)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[aurorawebsoftware/aauth

Laravel Aauth

412.1k1](/packages/aurorawebsoftware-aauth)

PHPackages © 2026

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