octopyid/laravel-impersonate
Laravel Impersonate lets admins log in as any user without passwords, then switch back safely. It includes middleware, events, and multi-guard support for secure, flexible user impersonation in Laravel apps.
package.json surface from our supply chain, which is a security and maintenance argument as much as a performance one — worth flagging to anyone who owns dependency policy.scopeImpersonatable + trait defaults + Impersonate::loginAs($user) mean the "integrate" estimate drops to roughly: install, add a scope, wire an authorization gate, ship. That's the number to compare against an internal build.Adopt when:
/_impersonate/users and /_impersonate/login) is, on its own, sufficient reason to schedule the upgrade.Look elsewhere when:
For executives (one paragraph): We evaluated LaraPersonate, a Laravel package that lets trusted staff sign in as another user for support, QA, and demos. Version 5 is a genuine maturity jump — the frontend dependency tree is gone entirely (smaller attack surface, less to maintain), the codebase now passes strict static analysis with no suppressions, and a high-severity information-disclosure vulnerability was fixed: unauthenticated users could previously enumerate your customer list through the package's API endpoints. If we run it anywhere in production on v4, upgrading is a security action, not a nice-to-have. The trade-off is a hard requirement on PHP 8.2+ and Laravel 12/13, plus a short but mandatory migration (renamed config/env keys, adding a database scope to the user model). Recommendation: upgrade immediately if we are already on v4 and a supported Laravel version; otherwise fold adoption into the next Laravel upgrade rather than starting a separate workstream.
For engineering (the working summary): Cleaner, smaller, stricter. Dropped jQuery/Select2 and the Node build; vanilla JS/CSS only. scopeImpersonatable moves filtering to the database, which fixes pagination .total() accuracy and improves search performance, and it now supports both scopeMethod() and Laravel 11+ #[Scope] attributes. Trait defaults (getImpersonateDisplayText() → $this->name, getImpersonateSearchField() → ['name']) mean zero config for basic use, and Impersonate::loginAs($user) gives a fluent backend path. Breaking changes to plan for: PHP 8.2+/Laravel 12–13; in-memory filtering is gone, so a scopeImpersonatable on the User model is now required, not optional; impersonate.enabled → impersonate.interface.enabled; IMPERSONATE_ENABLED/_WIDTH/_DELAY → IMPERSONATE_UI_ENABLED/_UI_WIDTH/_UI_DEBOUNCE. Non-negotiables we own regardless of version: an authorization gate on both API endpoints, audit logging of every impersonation start/stop, and session invalidation on exit — the package handles the login switch, not the governance around it.
How can I help you explore Laravel packages today?