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

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

omarpre/impersonate
===================

Impersonate users easily in Laravel apps. (Copy of original package as it is now abandoned)

v3.0.0(2y ago)02.1k↓50%MITPHPPHP ^7.3|^8.1

Since Sep 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/omarpre/impersonate)[ Packagist](https://packagist.org/packages/omarpre/impersonate)[ RSS](/packages/omarpre-impersonate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

Impersonate
===========

[](#impersonate)

A lightweight, yet useful package for user impersonation.

Impersonation can be a nice way to track down issues / bugs beyond our tests. With this package, it's easy to implement it, without touching the core of our app.

Configure the package as you need and it's ready to go!

Getting Started
---------------

[](#getting-started)

You can install the package with composer, using the `composer require omarpre/impersonate` command.

### Laravel 5.5 or higher

[](#laravel-55-or-higher)

If you are using version 5.5, there is nothing else to do. Since the package supports autodiscovery, Laravel will register the service provider automatically, behind the scenes.

### Laravel 5.4 and below

[](#laravel-54-and-below)

You have to register the service provider manually. Go to the `config/app.php` file and add the `Pine\Impersonate\ImpersonateServiceProvider::class` to the providers array.

### Disable the autodiscovery for the package

[](#disable-the-autodiscovery-for-the-package)

In some cases you may disable autodiscovery for this package. You can add the provider class to the `dont-discover` array to disable it.

Then you need to register it manually again.

Configuration
-------------

[](#configuration)

You may override the default configurations. To do that, first you have to publish the config file with the following command: `php artisan vendor:publish --provider=Pine\Impersonate\ImpersonateServiceProvider`. Then you can find the config file, at `config/impersonate.php`.

Middlewares
-----------

[](#middlewares)

By default the impersonating routes have with two middlewares, the `web` and the `auth`. But of course, it's definetly not enough. In the config file, at the middlewares section, you can add more middlewares, what you registered in your `Kernel.php` before, or you can add fully qualified classnames as well.

Routes
------

[](#routes)

The package brings two routes. One for imopersonating a user and one for revert to the original one.

The impersonate route's properties are the following:

- Path: `/impersonate/{user}`
- Name: `impersonate.impersonate`
- Controller@action: `Pine\Impersonate\Http\Controllers\ImpersonateController@impersonate`

The revert route's properties are the following:

- Path: `/impersonate/revert`
- Name: `impersonate.revert`
- Controller@action: `Pine\Impersonate\Http\Controllers\ImpersonateController@revert`

As you see, when we navigate a user to these routes, the action has to hit the server. That means, if you use something like Vue Router, please take care to use a normal link for these instead of the router's.

```

Revert

Revert
```

Redirection
-----------

[](#redirection)

After impersonating a user, or reverting we return with a redirection response. By default both action redirects to the `/home` path. You can configure both routes individually in the config file, at the redirect section.

Events
------

[](#events)

Both actions trigger an event when we hit them. You can setup your own listeners for these events, in the `EventServiceProvider`. For example:

```
protected $listen = [
    \Pine\Impersonate\Events\ChangedToUser::class => [
        // Listeners
    ],
    \Pine\Impersonate\Events\Reverted::class => [
        // Listeners
    ],
];
```

Also, you can access the impersonated user via the `ChangedToUser` event. Here is an example listener for that:

```
public function handle(ChangedToUser $event)
{
    // $event->user
}
```

Blade Directive
---------------

[](#blade-directive)

The package brings a blade directive to check easily if the user is in an impersonation mode or not. It's like a basic if statement.

```
@impersonate
    // You are impersonating
@else
    // You are in your own profile
@endimpersonate

```

Working with JS
---------------

[](#working-with-js)

Since the whole process is session based, we have the information about the current state only on the server-side. That means, if we want to integrate the package with an SPA, we need to extract the info and make it accessible in the front-end.

At the first load, we have the chance to fetch the current status to the `window` object. For example:

```

    @impersonate
        window.isImpersonating = true;
    @else
        window.isImpersonating = false;
    @endimpersonate

```

Contribute
----------

[](#contribute)

If you found a bug or you have an idea connecting the package, feel free to open an issue.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~18 days

Total

3

Last Release

942d ago

Major Versions

v1.0.0 → v2.0.02023-10-19

v2.0.0 → v3.0.02023-10-19

PHP version history (3 changes)v1.0.0PHP ^7.1

v2.0.0PHP ^7.3|^8.0

v3.0.0PHP ^7.3|^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65383832?v=4)[Nawaz Khan](/maintainers/nawazzz)[@nawazzz](https://github.com/nawazzz)

---

Top Contributors

[![nawazzzz](https://avatars.githubusercontent.com/u/103118074?v=4)](https://github.com/nawazzzz "nawazzzz (2 commits)")[![nawazm92](https://avatars.githubusercontent.com/u/26037518?v=4)](https://github.com/nawazm92 "nawazm92 (1 commits)")[![omarpre](https://avatars.githubusercontent.com/u/104169030?v=4)](https://github.com/omarpre "omarpre (1 commits)")

### Embed Badge

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

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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