Extensibility
configure() callbacks
ImpersonationManager::configure(
authorize: fn ($a, $b) => true,
user: fn () => Auth::guard('admin')->user(),
login: fn ($user) => Auth::guard('admin')->login($user, false),
resolveImpersonatee: fn (string $id) => Customer::findOrFail($id),
startResponse: fn ($request, $manager) => response()->noContent(),
stopResponse: fn ($request, $manager) => redirect('/admin'),
);
Omitted callbacks use the package defaults (respecting guard and
impersonatee_model from config).
Default login behavior
The default login handler calls Auth::login($user, false) — impersonation does
not inherit or set remember-me cookies.
Swapping the manager
Bind your subclass in a service provider:
$this->app->singleton(ImpersonationManager::class, CustomImpersonationManager::class);
ImpersonationManager::make() and configure() resolve through the container,
so subclasses can override protected default*Handler() methods.
Config knobs
Session key, guard, depth, and routing are all configurable — see Configuration.
Contract
Impersonateable is an empty marker. Implement it on any Eloquent model you
authenticate as or impersonate. The package does not require additional methods.
Continue to Compatibility.