nikfedorov / auto-login
Auto-login middleware for Laravel — logs in the first database user in allowed environments during development.
v1.0.0
2026-06-11 18:36 UTC
Requires
- php: ^8.2
- laravel/framework: ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0 || ^10.0 || ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-type-coverage: ^4.0
README
Middleware that automatically logs in the first database user in allowed environments — skip the login screen during development.
If no user exists yet, the request passes through unauthenticated. Run your seeders first.
Requirements
- PHP 8.2+
- Laravel 11 / 12 / 13
Installation
composer require nikfedorov/auto-login
Then register the middleware:
php artisan auto-login:install
This adds the middleware to bootstrap/app.php:
->withMiddleware(function (Middleware $middleware): void { $middleware->append(AutoLoginLocal::class); })
You can also register it manually instead of running the command.
Optionally publish the config:
php artisan vendor:publish --tag=auto-login-config
Configuration
| Env variable | Default | Description |
|---|---|---|
AUTOLOGIN_ENABLED |
true |
Enable or disable auto-login globally |
AUTOLOGIN_ENVIRONMENTS |
local |
Comma-separated list of allowed environments |
How it works
On each request:
- Skips if the user is already authenticated.
- Skips if
auto-login.enabledisfalse. - Skips if the current
APP_ENVis not inauto-login.environments. - Resolves the user model from
auth.providers.users.model, grabs the first record, and logs them in.
In any environment not listed in AUTOLOGIN_ENVIRONMENTS (e.g. production, staging) the middleware is a no-op.
Testing
composer test