PHPackages                             stanfortonski/laravel-twofactor - 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. stanfortonski/laravel-twofactor

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

stanfortonski/laravel-twofactor
===============================

Two-factor authentication for Laravel 7.x and 8.x via e-mail.

v1.0.2(5y ago)238MITPHPPHP &gt;=7.2

Since Jan 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/stanfortonski/Laravel-Twofactor)[ Packagist](https://packagist.org/packages/stanfortonski/laravel-twofactor)[ RSS](/packages/stanfortonski-laravel-twofactor/feed)WikiDiscussions main Synced yesterday

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Laravel-Twofactor
=================

[](#laravel-twofactor)

Two-factor authentication package for Laravel 7.x and 8.x via e-mail.

Information
===========

[](#information)

This package provides you to set of middleware, view, migration, routes with controllers, transaltions and methods to user model which allow you to set up 2FA vie email for your application.

Installation
============

[](#installation)

1. First install package via composer. Run `composer require stanfortonski/laravel-twofactor`.
2. Setup provider. In config/app.php add following code to bottom of providers:

```
'providers' => [
    //...
    Stanfortonski\Laraveltwofactor\ServiceProvider::class
],
```

3. Setup middleware. In app/Http/Kernel.php add following code to bottom of middlewares:

```
protected $routeMiddleware = [
    //...
    'twofactor' => \Stanfortonski\Laraveltwofactor\Middleware\TwoFactor::class
];
```

5. Use \\Stanfortonski\\Laraveltwofactor\\Traits\\TwoFactorable trait in User class with \\Illuminate\\Notifications\\Notifiable. Snippet: `use Notifiable, TwoFactorable;`
6. You have to publish config file twofactor.php. Run command: `php artisan vendor:publish --provider="Stanfortonski\Laraveltwofactor\ServiceProvider"`.
7. Run `php artisan migrate`.
8. Add line `$user->startTwoFactor()` in your login process. For example in Laravel/ui add this line in Auth\\LoginController@authenticated method before redirect.
9. Set up your email in .env.

Configuration
=============

[](#configuration)

In config/twofactor.php

1. If you want to disable twofactor/preferences routes set `preferences.allow` to false.
2. If you want to change expire time of 2FA code you will change `expire_duration`. Default value is 15 minutes.
3. Look at routes.login, routes.successful and routes.return that must be real routes name in your application. More in file itself.

Usage
=====

[](#usage)

You have to set twofactor middleware in routes. The way depends on you.

Example:

```
    Route::get('/home', function(){
        return view('home');
    })->middleware(['auth', 'twofactor']);
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Every ~21 days

Total

3

Last Release

1885d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/486ac8f1ac33b8a9018d25e1f2828398089d88adfe9890325cc9a5fad17fe9f0?d=identicon)[stanfortonski](/maintainers/stanfortonski)

---

Top Contributors

[![stanislawfortonski](https://avatars.githubusercontent.com/u/25102093?v=4)](https://github.com/stanislawfortonski "stanislawfortonski (24 commits)")

---

Tags

authorizationlaravellaravel-7laravel-7-packagelaravel-8laravel-8-packagelaravel-frameworklaravel-packagepackagetwo-factortwo-factor-authtwo-factor-authenticationlaravellaravel 7laravel 8authAuthentication2falaravel-packagelaravel-plugine-mailtwofactorlaravel-module

### Embed Badge

![Health badge](/badges/stanfortonski-laravel-twofactor/health.svg)

```
[![Health](https://phpackages.com/badges/stanfortonski-laravel-twofactor/health.svg)](https://phpackages.com/packages/stanfortonski-laravel-twofactor)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[lab404/laravel-auth-checker

Laravel Auth Checker allows you to log users authentication, devices authenticated from and lock intrusions.

223164.9k2](/packages/lab404-laravel-auth-checker)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[rickycezar/laravel-jwt-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

24117.6k](/packages/rickycezar-laravel-jwt-impersonate)[awes-io/auth

Laravel Authentication package with built-in two-factor (Authy) and social authentication (Socialite).

3826.7k1](/packages/awes-io-auth)[hapidjus/laravel-impersonate-ui

UI for 404labfr/laravel-impersonate

371.5k](/packages/hapidjus-laravel-impersonate-ui)

PHPackages © 2026

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