Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Impersonate Laravel Package

j84115/impersonate

Simple Laravel package to temporarily impersonate other users via /impersonate/login/{user_id} and /impersonate/logout. Add service provider, implement ImpersonateUser on your User model to define who can impersonate and who can be impersonated, then register Route::impersonate().

View on GitHub
Deep Wiki
Context7

Laravel-Impersonate

A simple Laravel Package to temporarily login as other users.

Usage

You can login to another user through {app_url}/impersonate/login/{user_id}.

And you can end the session with {app_url}/impersonate/logout.

Install Package

composer require j84115/impersonate Not yet on Packagist. Install manually.

Add Sevice Provider

Add the Package to config/app.php

J84115\Impersonate\ImpersonateServiceProvider::class,

Add Interface To User

Add the Interface to your User Model. Typically app/Models/User.php.

use J84115\Impersonate\Interfaces\ImpersonateUser;

Implement the interface.

class User extends Authenticatable implements ImpersonateUser

Then add your conditions for who can impersonate a user.

    public function impersonator(): bool
    {
        return $this->role === 'admin';
    }

    public function impersonatable(): bool
    {
        return $this->email !== 'admin';
    }

Routing

Add the following macro to your routes. Typically guarded with auth Middleware in routes/web.php.

Route::impersonate();
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity