PHPackages                             haikallfiqih/laravel-magic-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. haikallfiqih/laravel-magic-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

haikallfiqih/laravel-magic-auth
===============================

A secure passwordless authentication package using magic links

v1.0.0(1y ago)13MITPHPPHP ^8.0

Since Dec 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/haikallfiqih/laravel-magic-auth)[ Packagist](https://packagist.org/packages/haikallfiqih/laravel-magic-auth)[ RSS](/packages/haikallfiqih-laravel-magic-auth/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel Magic Auth
==================

[](#laravel-magic-auth)

A secure, flexible passwordless authentication package for Laravel using magic links. Supports multiple notification channels including email, WhatsApp, and SMS.

Features
--------

[](#features)

- 🔐 Secure passwordless authentication
- 📧 Multi-channel notifications (Email, WhatsApp, SMS)
- ⚡ Easy integration with Laravel's authentication system
- 🛡️ Rate limiting and link expiration
- 🔄 Event-driven architecture
- 🎨 Customizable templates and messages
- 🚦 Multiple guard support

Installation
------------

[](#installation)

```
composer require haikallfiqih/laravel-magic-auth
```

### Configuration

[](#configuration)

1. Publish the configuration and migrations:

```
php artisan vendor:publish --provider="LaravelLinkAuth\MagicAuth\MagicAuthServiceProvider"
```

2. Run the migrations:

```
php artisan migrate
```

3. Add these environment variables to your `.env` file:

```
# For Email (default)
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="Your App Name"

# For WhatsApp/SMS (optional)
MAGIC_AUTH_WHATSAPP_PROVIDER=twilio
MAGIC_AUTH_WHATSAPP_FROM=+1234567890
MAGIC_AUTH_SMS_FROM=+1234567890
TWILIO_SID=your-twilio-sid
TWILIO_TOKEN=your-twilio-token
```

Basic Usage
-----------

[](#basic-usage)

### Sending Magic Links

[](#sending-magic-links)

```
use LaravelLinkAuth\MagicAuth\Facades\MagicAuth;

// Send via email (default)
MagicAuth::sendMagicLink('user@example.com');

// Send via WhatsApp
MagicAuth::sendMagicLink('+1234567890', 'web', [], ['whatsapp']);

// Send via SMS
MagicAuth::sendMagicLink('+1234567890', 'web', [], ['sms']);

// With custom attributes for new users
MagicAuth::sendMagicLink('user@example.com', 'web', [
    'name' => 'John Doe',
    'company_id' => 1
]);
```

### Route Configuration

[](#route-configuration)

Add these routes to your `web.php`:

```
use LaravelLinkAuth\MagicAuth\Http\Controllers\MagicAuthController;

Route::post('/magic-link', [MagicAuthController::class, 'sendMagicLink'])
    ->name('magic-auth.send');

Route::get('/auth/verify', [MagicAuthController::class, 'verify'])
    ->name('magic-auth.verify')
    ->middleware('signed');
```

### Event Handling

[](#event-handling)

```
use LaravelLinkAuth\MagicAuth\Facades\Events;
use LaravelLinkAuth\MagicAuth\Events\MagicAuthEvents;

// Before generating a magic link
Events::listen(MagicAuthEvents::GENERATING, function ($notifiable, $guard, $attributes) {
    // Validate or modify attributes
});

// After sending a magic link
Events::listen(MagicAuthEvents::SENT, function ($notifiable, $guard, $linkId) {
    // Log or track magic link usage
});

// When verification succeeds
Events::listen(MagicAuthEvents::VERIFICATION_COMPLETED, function ($user, $guard) {
    // Handle successful login
});
```

WhatsApp/SMS Integration
------------------------

[](#whatsappsms-integration)

To use WhatsApp or SMS notifications:

1. Install Twilio SDK:

```
composer require twilio/sdk
```

2. Configure your Twilio credentials in `.env`:

```
TWILIO_SID=your-twilio-sid
TWILIO_TOKEN=your-twilio-token
MAGIC_AUTH_WHATSAPP_FROM=+1234567890
MAGIC_AUTH_SMS_FROM=+1234567890
```

Configuration Options
---------------------

[](#configuration-options)

```
return [
    // Link expiration time in minutes
    'expires' => 15,

    // Authentication guards configuration
    'guards' => [
        'web' => [
            'provider' => 'users',
            'model' => \App\Models\User::class,
            'redirect_on_success' => '/dashboard',
        ],
    ],

    // Rate limiting settings
    'throttle' => [
        'max_attempts' => 5,
        'decay_minutes' => 10,
    ],

    // Available notification channels
    'channels' => [
        'default' => ['mail'],
        'available' => ['mail', 'whatsapp', 'sms'],
    ],
];
```

Security
--------

[](#security)

- Links are single-use and expire after a configurable time
- Rate limiting prevents abuse
- Signed URLs prevent tampering
- Automatic cleanup of expired links

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Haikal Fiqih](https://github.com/haikallfiqih)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

580d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/92772661?v=4)[Haikal Fiqih](/maintainers/haikallfiqih)[@haikallfiqih](https://github.com/haikallfiqih)

---

Top Contributors

[![haikallfiqih](https://avatars.githubusercontent.com/u/92772661?v=4)](https://github.com/haikallfiqih "haikallfiqih (6 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/haikallfiqih-laravel-magic-auth/health.svg)

```
[![Health](https://phpackages.com/badges/haikallfiqih-laravel-magic-auth/health.svg)](https://phpackages.com/packages/haikallfiqih-laravel-magic-auth)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

59437.0k9](/packages/jeremy379-laravel-openid-connect)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3417.0k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
