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

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

motomedialab/impersonate
========================

A user impersonation package for Laravel applications.

v1.1.0(1mo ago)016MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Jul 10Pushed 1mo agoCompare

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

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

🎭 [MotoMediaLab](https://motomedialab.com/) Impersonate
=======================================================

[](#-motomedialab-impersonate)

[![Latest Version on Packagist](https://camo.githubusercontent.com/040390df826982fbb443a89264a76354378b53ff50726436bb10c2ea0d7a9cad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f746f6d656469616c61622f696d706572736f6e6174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/motomedialab/impersonate)[![Total Downloads](https://camo.githubusercontent.com/a769b81fd2a852f189d60754fdffb22e50b0126c2a4cbc3a353abb42446b00f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f746f6d656469616c61622f696d706572736f6e6174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/motomedialab/impersonate)[![GitHub Actions](https://github.com/motomedialab/impersonate/actions/workflows/tests.yml/badge.svg)](https://github.com/motomedialab/impersonate/actions/workflows/tests.yml/badge.svg)

A sleek, robust, and customisable user impersonation package for Laravel applications. This package allows administrators to securely log in as other users, aiding in replication of bugs, general support, and user management.

---

📦 Installation
--------------

[](#-installation)

You can install the package via Composer by running the following command in your terminal:

```
composer require motomedialab/impersonate
```

⚙️ Configuration
----------------

[](#️-configuration)

### 1. Publish Configuration (Optional)

[](#1-publish-configuration-optional)

You can publish the configuration file to customize the middleware groups to which the impersonation middleware is applied:

```
php artisan vendor:publish --tag="impersonate-config"
```

This will create a `config/impersonate.php` file where you can define the middleware groups (defaults to `['web', 'api']`).

### 2. Implement the Contract on Your User Model

[](#2-implement-the-contract-on-your-user-model)

To control who can impersonate others, and who can be impersonated, your `User` model (or authenticatable model) must implement the `Motomedialab\Impersonate\Contracts\ImpersonatableUser` contract.

This contract requires the implementation of two methods:

```
