PHPackages                             whyounes/laravel-two-factor-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. whyounes/laravel-two-factor-auth

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

whyounes/laravel-two-factor-auth
================================

Laravel two factor authentication

v1.0.0(9y ago)8121MITPHPPHP ^5.5.9 || ^7.0

Since Dec 21Pushed 9y ago2 watchersCompare

[ Source](https://github.com/Whyounes/laravel-two-factor-auth)[ Packagist](https://packagist.org/packages/whyounes/laravel-two-factor-auth)[ Docs](https://github.com/whyounes/laravel-two-factor-auth)[ RSS](/packages/whyounes-laravel-two-factor-auth/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (8)Versions (2)Used By (0)

Laravel Two Factor Authentication
=================================

[](#laravel-two-factor-authentication)

Two Factor Authentication for Laravel 5.3+

 [ ![Build status](https://camo.githubusercontent.com/5a69b5ddc91ebcfa3d7df5f55d9ae98bc213602631cb05c39b1214725c4ce4d2/68747470733a2f2f7472617669732d63692e6f72672f5768796f756e65732f6c61726176656c2d74776f2d666163746f722d617574682e7376673f6272616e63683d6d6173746572) ](https://travis-ci.org/Whyounes/laravel-two-factor-auth) [ ![](https://camo.githubusercontent.com/f7c561f741393045e318f73c9b88199553c57a19fe6c30a1fa19671b25c04db3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63356164616163382d326138352d346530352d616339352d6336333566663463386132332f6d696e692e706e67) ](https://insight.sensiolabs.com/projects/c5adaac8-2a85-4e05-ac95-c635ff4c8a23)

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

[](#installation)

Add the package to your project using Composer:

```
composer require whyounes/laravel-two-factor-auth
```

Publish package assets:

```
php artisan vendor:publish
```

Run the migrations:

```
php artisan migrate
```

Add it to you providers list:

```
// config/app.php

// ...
'providers' => [
    // ...
    Whyounes\TFAuth\TwoFAProvider::class,
};
```

Add the `TFAuthTrait` trait to your user model:

```
// app/User.php

class User extends Authenticatable
{
    use \Whyounes\TFAuth\Models\TFAuthTrait;

    // ...
}
```

Configurations
--------------

[](#configurations)

There are only two configurations that you can set:

- `delete_verification_code_after_auth`: Set it to `true` if you want to delete unused verification codes after login.
- `verification_code_length`: How long the verification code is.

Verification Code Sender
------------------------

[](#verification-code-sender)

By default, the package uses [Twilio](http://twilio.com/) to send verification codes (SMS and Phone). You can easily change it like this:

```
use Whyounes\TFAuth\Contracts\VerificationCodeSenderInterface;

class MyService implements VerificationCodeSenderInterface
{
    public function sendCodeViaSMS($code, $phone, $message = "Your verification code is %s")
    {
        // Send code and return boolean for status
    }

    public function sendCodeViaPhone($code, $phone, $message = "Your verification code is %s")
    {
        // Send code and return boolean for status
    }
}
```

Next we should switch implementation in the container:

```
use Whyounes\TFAuth\Contracts\VerificationCodeSenderInterface;

class AppProvider extends ServiceProvider
{
    public function register()
    {
        // ...
        $this->app->bind(VerificationCodeSenderInterface::class, MyService::class);
    }
}
```

That's it, your new service is going to be used for sending verification codes. If you add a new service implementation, you can submit a new pull request and I'll add it to the package :)

Example
-------

[](#example)

Check [this repository](https://github.com/Whyounes/laravel-twilio-2fa) for a demo application using the package.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

3428d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e77e863a88494fe41ab35f0d3fa40d08172040ea801aa558672af608da4e1e1?d=identicon)[Whyounes](/maintainers/Whyounes)

---

Top Contributors

[![Whyounes](https://avatars.githubusercontent.com/u/1175548?v=4)](https://github.com/Whyounes "Whyounes (16 commits)")

---

Tags

authPasswordless

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/whyounes-laravel-two-factor-auth/health.svg)

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

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[cesargb/laravel-magiclink

Create secure link for access to private data or login in Laravel without password

4571.3M](/packages/cesargb-laravel-magiclink)

PHPackages © 2026

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