
Laravel Login link is a Blade component to quickly connect to your local environment.
🚀 spatie/laravel-login-link has been publishedhttps://t.co/IIcQyyRPbg
👤 Using this package you can render login links in local environment. No more having to remember your test user’s email/password.
👍 I can see us using it in every project. pic.twitter.com/rZNBRSL0Ec
— Freek Van der Herten 🔭 (@freekmurze) May 30, 2022
After installing the login link package, logging in locally as an administrator or normal user is as easy as adding the following blade snippet:
1@env('local')
2 <div class="space-y-2">
3 <x-login-link email="[email protected]" label="Login as admin"/>
4 <x-login-link email="[email protected]" label="Login as regular user"/>
5 div>
6@endenv
Clicking on a login link will automatically log you in without having to remember or enter any credentials. Your non-local environments will not display these links, but your local login page might look like this:
According to Freek Van der Herten of Spatie, this package was envisioned and created by Spatie to manage predefined user credentials for various roles and a package designed to be shared with the open source community:
When developing an app with an admin section (or any other non-public section), you’ll likely have test users to login. In large teams that work on many different applications, it can be cumbersome to keep track of the correct credentials. Is the user account “[email protected]”, or “[email protected]”, or even “[email protected]”? Is this password “password”, “secret” or something else? How can I log in with a user who has a different role?
This package solves this problem by providing a component to render a login link. When you click on it, you will be connected.
freek wrote a detailed introductory article about this package if you want to know more about the background and use case of this package. You can also read more about configuring this package and view the source code on GitHub.