nikfedorov/auto-login
最新稳定版本:v1.0.0
Composer 安装命令:
composer require nikfedorov/auto-login
包简介
Auto-login middleware for Laravel — logs in the first database user in allowed environments during development.
README 文档
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
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-11