- What is cesargb/laravel-magiclink used for?
- It creates magic links that let users authenticate in a Laravel application without a password, or access private content. You generate a link for a user and the package handles token validation and login. It fits passwordless login flows, invitations, and one-time private URLs.
- How do I install cesargb/laravel-magiclink in Laravel?
- Install it with Composer using composer require cesargb/laravel-magiclink. Laravel auto-discovers the service provider, and you can publish the package configuration if you need to customize defaults. After that, generate links through the MagicLink facade or class.
- How do I create a magic link for a user in Laravel?
- Use the MagicLink facade or class and pass the authenticatable user model to create a link. The returned object exposes the generated URL, which you can email or deliver to the user. The URL contains a secure token tied to that user.
- Does laravel-magiclink support passwordless login out of the box?
- Yes, the package is designed for passwordless authentication. A valid magic link logs the associated user into the configured guard. You can customize redirects and post-login behavior through the package configuration.
- How do I configure magic link expiration and usage limits?
- Publish the package configuration file and adjust the expiration and visit limit settings. Links should be short-lived and limited to prevent reuse. Review the expires_in and max_visits options to match your security requirements.
- Can I use laravel-magiclink to protect private content instead of login?
- Yes, the package can generate links for accessing private content, not only for authentication. You can validate the magic link before showing protected resources or running a restricted action. This makes it useful for one-time downloads, invitations, and gated pages.
- Which Laravel versions does cesargb/laravel-magiclink support?
- The package supports modern Laravel versions, but the exact range depends on the release. Check the composer.json and README on GitHub for the current version constraints before upgrading. Laravel package auto-discovery works on the supported versions.
- Is laravel-magiclink secure for production use?
- Magic links are bearer tokens, so treat them like passwords. Use HTTPS, short expiration times, single-use limits, and avoid logging the full URLs. The package provides token validation and configurable limits, but you must secure delivery and storage.
- How do I test magic link authentication in Laravel?
- Use Laravel testing helpers to generate a link for a factory-created user and visit the URL. Assert that the user is authenticated and redirected as expected. You can also freeze time to test expiration and reuse limits.
- What are alternatives to cesargb/laravel-magiclink?
- Alternatives include Laravel signed URLs for temporary access, custom passwordless login with signed routes, or other magic link packages. Choose based on whether you need full authentication, token limits, and event hooks. cesargb/laravel-magiclink bundles these concerns for you.