agile-creative-minds / laravel-dev-login-link
Dev-only magic login link command for Laravel
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/agile-creative-minds/laravel-dev-login-link
Requires
- php: ^8.2
- illuminate/auth: ^11.0|^12.0
- illuminate/console: ^11.0|^12.0
- illuminate/routing: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^11.0
README
A dev-only Artisan command that generates one-time login links for Laravel.
Why this exists: During local development, you often need to quickly log in as different users without resetting passwords or navigating login forms. This package provides a single command to generate a secure, short-lived login link — saving time and reducing friction in your dev workflow.
Installation
composer require agile-creative-minds/laravel-dev-login-link --dev
The package auto-discovers, so no manual service provider registration is needed.
Usage
# Generate a login link for the first user # (if no users exist, a default admin user admin@example.com is created) php artisan dev:login-link # Generate a login link for a specific user php artisan dev:login-link 5
The generated URL is valid for 10 minutes.
Security
This package is designed for local development only:
- Routes are only registered when
APP_ENVislocal,development, ortesting - The command refuses to run in production environments
- URLs use Laravel's signed routes with short expiration times
- Requires shell/container access to generate links
Never enable this in production.
How It Works
- The command generates a temporary signed URL using
URL::temporarySignedRoute('dev.login', ...) - When visited, the
signedmiddleware verifies the URL hasn't been tampered with or expired - If valid, the user is logged in via
Auth::login()and redirected to/dashboard(or/if no dashboard route exists)
Troubleshooting
"I clicked the link but nothing seems different"
On a fresh Laravel install without an auth starter kit (Breeze, Jetstream, etc.), there's no /dashboard route or visible auth UI. The login is working, but you're redirected to / which doesn't show login status.
Solution: Install Laravel Breeze for a complete auth experience:
composer require laravel/breeze --dev php artisan breeze:install blade php artisan migrate
After this, the login link will redirect you to /dashboard where you'll see you're authenticated.
"I get redirected to the login page"
This usually means the session isn't persisting. Make sure your Laravel app has:
SESSION_DRIVERset in.env(e.g.,database,file,cookie)- The
sessionstable migrated if usingdatabasedriver - The
/dev-login/{user}route uses thewebmiddleware group (handled by the package by default)
"Route [dev.login] not defined"
The route only loads in local, development, or testing environments. Check your APP_ENV in .env:
APP_ENV=local
Requirements
- PHP 8.2+
- Laravel 11.x or 12.x (any app using the default
webguard andusersprovider) - For best experience: Laravel Breeze, Jetstream, or custom auth scaffolding
License
MIT