PHPackages                             stickee/laravel-2fa - 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. stickee/laravel-2fa

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

stickee/laravel-2fa
===================

Stickee Laravel 2FA - add two factor authentication

v1.0.9(4mo ago)02.3k1[1 PRs](https://github.com/stickeeuk/laravel-2fa/pulls)MITPHPPHP ^7.2.0|^8.0CI failing

Since Apr 7Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/stickeeuk/laravel-2fa)[ Packagist](https://packagist.org/packages/stickee/laravel-2fa)[ Docs](https://www.stickee.co.uk)[ RSS](/packages/stickee-laravel-2fa/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (9)Dependencies (5)Versions (12)Used By (0)

Stickee Laravel 2FA
===================

[](#stickee-laravel-2fa)

This a composer module for adding two factor authentication.

Contents
--------

[](#contents)

- [Quick Start](#quick-start)
- [Installation](#installation)
    - [Manual Registration](#manual-registration)
- [Configuration](#configuration)
    - [Environment Variables](#environment-variables)
    - [Config File](#config-file)
- [Customisation](#customisation)
- [Developing](#developing)

Quick Start
-----------

[](#quick-start)

1. `composer require stickee/laravel-2fa`
2. `php artisan migrate`

2FA is now enabled, but not enforced. To enforce it for all users, set in your `.env`: `LARAVEL_2FA_REQUIRED=true`

Users will be prompted to enroll in 2FA when they log in.

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

[](#installation)

`composer require stickee/laravel-2fa`

This module ships with a Laravel service provider which will be automatically registered for Laravel 5.5+.

### Manual registration

[](#manual-registration)

The module can be manually registered by adding this to the `providers` array in `config/app.php`:

```
Stickee\Laravel2fa\ServiceProvider::class,

```

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

NameTypeDefaultDescriptionLARAVEL\_2FA\_ENABLED`bool``true`Used to disable 2FA checking completelyLARAVEL\_2FA\_REQUIRED`bool``false`Require 2FA for all users### Config File

[](#config-file)

Publish the configuration file to your project with this command:

`php artisan vendor:publish --provider=Stickee\\Laravel2fa\\ServiceProvider --tag=config`

NameTypeDefaultDescriptionenabled`bool``env('LARAVEL_2FA_ENABLED', true)`Enable or disable 2-factor checkinguser\_class`string``\App\User::class`The user model classrequired`bool``env('LARAVEL_2FA_REQUIRED', false)`If 2FA is required or optional for users (force enrollment)middleware\_groups`array``['web', 'nova']`Middleware groups to add 2FA to. It will always only apply to authenticated usersroutes\_middleware`array``['web']`Middleware to apply to routes used by the 2FA system (e.g. /2fa/register)routes\_prefix`string``'2fa'`Prefix for routes used by the 2fa systemstate\_store`string``\Stickee\Laravel2fa\StateStores\SessionStateStore::class`A class implementing `\Stickee\Laravel2fa\Contracts\StateStore` to store statesession\_prefix`string``'laravel-2fa'`Prefix for variables stored in the session to prevent collisionsdrivers`array``['google' => \Stickee\Laravel2fa\Drivers\Google::class]`A list of classes implementing \\Stickee\\Laravel2fa\\Contracts\\Driver. The key should be the driver nameqr\_code\_generator`string``\BaconQrCode\Renderer\Image\SvgImageBackEnd::class`A backend for Bacon QR Code - one of: `\BaconQrCode\Renderer\Image\ImagickImageBackEnd`, `\BaconQrCode\Renderer\Image\SvgImageBackEnd`, `\BaconQrCode\Renderer\Image\EpsImageBackEnd`. To use a completeley custom generator see [How Do I](#how-do-i)qr\_code\_size`int``400`The size in pixels of the QR codelifetime`int``0`The number of minutes of inactivity a user is allowed before they must reauthenticate. Set to zero for no limitkeep\_alive`bool``true`Whether to update the last activity time with each pageview. If set to `false` then "lifetime" becomes time since loginprevent\_reuse`bool``false`Prevent the user from logging in twice with the same coderecovery\_codes\_count`int``10`How many recovery codes to generate when a user registersredirect\_after\_login`string``'/'`The URL to redirect to after logging in (if we don't know where the user was trying to get to)redirect\_after\_logout`string``'/'`The URL to redirect to after logging outapp\_name`?string``null`The app name to use in the authenticator (use null to use `app.name`)username\_attribute`string``'email'`The attribute on the User model to use as the username in the authenticatorCustomisation
-------------

[](#customisation)

The package is highly customisable - most parts can be swapped out for your own implementation if required.

### How Do I...?

[](#how-do-i)

- Change the templates
    - Publish the views to your project with `php artisan vendor:publish --provider=Stickee\\Laravel2fa\\ServiceProvider --tag=laravel-views` and edit them there.
- Customise the text / add a translation
    - Publish the translations to your project with `php artisan vendor:publish --provider=Stickee\\Laravel2fa\\ServiceProvider --tag=translations` and edit them there.
- Change the QR code generator
    - To change to one of the built-in BaconQrCode backends, change the config variable `qr_code_generator`. At the time of writing, supported backends are `\BaconQrCode\Renderer\Image\ImagickImageBackEnd::class``\BaconQrCode\Renderer\Image\SvgImageBackEnd::class``\BaconQrCode\Renderer\Image\EpsImageBackEnd::class`
    - To use something completely different, create a class implementing `\Stickee\Laravel2fa\Contracts\QrCodeGenerator` and bind it to that interface in your service provider
- Create a custom driver / provider
    - Implement `\Stickee\Laravel2fa\Contracts\Driver` and register it in your `laravel-2fa.drivers` config. To make things easier you can probably extend `\Stickee\Laravel2fa\Drivers\AbstractDriver`.

Developing
----------

[](#developing)

The easiest way to make changes is to make the project you're importing the module in to load the module from your filesystem instead of the composer repository, like this:

1. `composer remove stickee/laravel-2fa`
2. Edit `composer.json` and add ```
    "repositories": [
            {
                "type": "path",
                "url": "../laravel-2fa"
            }
        ]

    ```

    where "../laravel-2fa" is the path to where you have this project checked out
3. `composer require stickee/laravel-2fa`

**NOTE:** Do not check in your `composer.json` like this!

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance78

Regular maintenance activity

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~268 days

Recently: every ~315 days

Total

9

Last Release

121d ago

PHP version history (2 changes)1.0.0PHP ^7.2.0

v1.0.5PHP ^7.2.0|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/48593081?v=4)[Greg Pinnington](/maintainers/stickeegreg)[@stickeegreg](https://github.com/stickeegreg)

---

Top Contributors

[![stickeegreg](https://avatars.githubusercontent.com/u/48593081?v=4)](https://github.com/stickeegreg "stickeegreg (7 commits)")[![stickeematt](https://avatars.githubusercontent.com/u/100570207?v=4)](https://github.com/stickeematt "stickeematt (5 commits)")[![stickeedavid](https://avatars.githubusercontent.com/u/41327792?v=4)](https://github.com/stickeedavid "stickeedavid (4 commits)")[![RoBorg](https://avatars.githubusercontent.com/u/702158?v=4)](https://github.com/RoBorg "RoBorg (3 commits)")[![stickeetom](https://avatars.githubusercontent.com/u/97950918?v=4)](https://github.com/stickeetom "stickeetom (2 commits)")[![ZebraNorth](https://avatars.githubusercontent.com/u/6115962?v=4)](https://github.com/ZebraNorth "ZebraNorth (1 commits)")

---

Tags

laravel2fa

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stickee-laravel-2fa/health.svg)

```
[![Health](https://phpackages.com/badges/stickee-laravel-2fa/health.svg)](https://phpackages.com/packages/stickee-laravel-2fa)
```

###  Alternatives

[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.9M53](/packages/jeffgreco13-filament-breezy)[statamic/cms

The Statamic CMS Core Package

4.8k3.5M920](/packages/statamic-cms)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[stephenjude/filament-two-factor-authentication

Filament Two Factor Authentication: Google 2FA + Passkey Authentication

84192.9k8](/packages/stephenjude-filament-two-factor-authentication)[spatie/laravel-passkeys

Use passkeys in your Laravel app

470755.5k32](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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