PHPackages                             top20ofe/two-factor-authentication - 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. top20ofe/two-factor-authentication

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

top20ofe/two-factor-authentication
==================================

Two Factor Authentication (2FA) for Laravel

0.1(5y ago)0276MITPHPPHP &gt;=7.1

Since Mar 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/top20oferti/two-factor-authentication)[ Packagist](https://packagist.org/packages/top20ofe/two-factor-authentication)[ RSS](/packages/top20ofe-two-factor-authentication/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

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

[](#installation)

**1. Composer Install**

```
$ composer require top20ofe/two-factor-authentication
```

*Note* - If your're using Laravel 5.5 or newer version then auto-discovery-pacakge would automatically update the providers and you could skip to **Step 3**

**2. Add Service Provider**

After requiring the package add `TwoFactorAuthenticationServiceProvider::class` into providors array in `app.php` confi file

```
[
 'providers' => [
    //...
    Top20ofe\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider::class
  ]
]
```

**3. Publish the ConfigFile**

Publish config file

```
$ php artisan vendor:publish --provider="Top20ofe\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider" --tag=config

```

Once the config file is published you can navigate to config directory of your application and look for `2fa-config.php` file and change configuration as you want.

**4. Run Migrations**

Now run the migration

```
$ php artisan migrate
```

It will use the default User model and adds two columns `is_2fa_enabled` and `secret_key`.

**5. Add `AuthenticatesUserWith2FA` trait in the LoginController**

Now the config file is placed. The last thing to do is addding `AuthenticatesUsersWith2FA` trait in the `Http/Controllers/Auth/LoginController.php` file which helps to stop user at verify-2fa page to enter TOTP token after each login.

The final snippet will look like this.

```
use AuthenticatesUsers, AuthenticatesUsersWith2FA {
    AuthenticatesUsersWith2FA::authenticated insteadof AuthenticatesUsers;
}
```

Note: Don't forget to include use statement `use Top20ofe\TwoFactorAuthentication\AuthenticatesUsersWith2FA` in the header.

**6. Setup 2FA for user**

**• Enable 2FA**

Now login to the application and visit `/setup-2fa/` route, which will show a barcode which can be scanned either using Google Authenticator or Authy mobile application as described above. Scan that code and click **Enable Two Factor Authentication**.

**• Disable 2FA**

To disable Two Factor, visit `/setup-2fa` route, which will now show a **Disable Two Factor Authentication** button. Click to disable 2FA for your account.

**7. Testing 2FA**

Now to test 2FA, perform logout and log back in again, it will ask you to enter Token which can be obtain from the authenticator mobile application. Enter the token and you're logged in.

### Additionally

[](#additionally)

If you want to publish views, and migration as well along with config file then run

```
$ php artisan vendor:publish --provider="Top20ofe\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider"

```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Every ~0 days

Total

2

Last Release

1881d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b1e4178038b4ddb28810fa95e0857adb548346db74c5c17cd92f84767a68dd0?d=identicon)[top20](/maintainers/top20)

---

Top Contributors

[![top20oferti](https://avatars.githubusercontent.com/u/61975373?v=4)](https://github.com/top20oferti "top20oferti (5 commits)")

---

Tags

laravelRFC 6238Authentication2fatwo-factorlaravel 5

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/top20ofe-two-factor-authentication/health.svg)

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

###  Alternatives

[laragear/two-factor

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

339785.3k8](/packages/laragear-two-factor)[thecodework/two-factor-authentication

Two Factor Authentication (2FA) for Laravel

225.5k](/packages/thecodework-two-factor-authentication)[scheb/2fa-google-authenticator

Extends scheb/2fa-bundle with two-factor authentication using Google Authenticator

298.2M30](/packages/scheb-2fa-google-authenticator)[scheb/2fa-totp

Extends scheb/2fa-bundle with two-factor authentication using TOTP

292.7M22](/packages/scheb-2fa-totp)[kelunik/two-factor

Two factor authentication.

371.9k1](/packages/kelunik-two-factor)[sicaboy/laravel-mfa

A Laravel package of Multi-factor Authentication (MFA/2FA) with a middleware.

101.2k](/packages/sicaboy-laravel-mfa)

PHPackages © 2026

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