Projectslaravel-impersonationUpgrade

Laravel Impersonation

Package

Session-based user impersonation for Laravel.

Upgrade Guide

Upgrade

First stable release.

Added

  • Config options: session_key, guard, routing.prefix, routing.middleware, routing.names.*
  • Stack helpers: originalUser(), impersonator(), impersonations()
  • Cancellable ImpersonationStarting (abort() or listener returning false)
  • Middleware aliases impersonating and not-impersonating
  • Package exception rendering to 401/403
  • Topic-based documentation under docs/ for bradietilley.dev
  • LICENSE.md and contributor composer scripts

Changed

  • Requires PHP 8.3+ and Laravel 13
  • routing.enabled defaults to false
  • Package routes use configurable prefix (default /impersonation/...) with web + auth middleware
  • Default login uses Auth::login($user, false) (no remember-me)
  • ImpersonationFinished dispatches after restore/login/save
  • Events no longer implement ShouldQueue

Removed

  • Laravel 11 support
  • Hardcoded /api/impersonation/... route paths

Migration from 0.1

  1. Upgrade to PHP 8.3+ and Laravel 13
  2. Publish config and set routing.enabled to true if you relied on package routes
  3. Update route URLs/names if you linked to the old /api/impersonation/... paths
  4. Ensure ImpersonationFinished listeners tolerate post-restore timing
  5. Move any ShouldQueue expectation from events onto listeners
  6. Implement Impersonateable on your user model if you have not already