PHPackages                             robthree/twofactorauth - 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. robthree/twofactorauth

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

robthree/twofactorauth
======================

Two Factor Authentication

v3.0.3(4mo ago)1.2k10.5M—2.4%143[1 issues](https://github.com/RobThree/TwoFactorAuth/issues)[2 PRs](https://github.com/RobThree/TwoFactorAuth/pulls)20MITPHPPHP &gt;=8.2.0CI passing

Since Mar 23Pushed 4mo ago46 watchersCompare

[ Source](https://github.com/RobThree/TwoFactorAuth)[ Packagist](https://packagist.org/packages/robthree/twofactorauth)[ Docs](https://github.com/RobThree/TwoFactorAuth)[ Fund](https://paypal.me/robiii)[ GitHub Sponsors](https://github.com/RobThree)[ RSS](/packages/robthree-twofactorauth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (27)Used By (20)

[![Logo](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/logo.png)](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/logo.png) PHP library for Two Factor Authentication
=======================================================================================================================================================================================================

[](#-php-library-for-two-factor-authentication)

[![Build status](https://camo.githubusercontent.com/211e3b19ee4c5cae3f613df372ee59ca1a8173d2c66c858e5d8d50f2d1d4496c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f6274687265652f74776f666163746f72617574682f746573742e796d6c3f6272616e63683d6d6173746572)](https://github.com/RobThree/TwoFactorAuth/actions?query=branch%3Amaster) [![Latest Stable Version](https://camo.githubusercontent.com/802b233e5c2ed29f4fd96f4cb2ddee9f4ad378d6ce223b37cb96b69e2767aa33/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6274687265652f74776f666163746f72617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/robthree/twofactorauth) [![License](https://camo.githubusercontent.com/1e632bb70a6d1a30c559f4c2cf4030548efb90ed2bee73006a33ca6adc4c65d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f726f6274687265652f74776f666163746f72617574682e7376673f7374796c653d666c61742d737175617265)](LICENSE) [![Downloads](https://camo.githubusercontent.com/be527f90e63919b3387bfe416e76edfa2a6aee8001c083a73ea3ea606665b553/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6274687265652f74776f666163746f72617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/robthree/twofactorauth) [![PayPal donate button](https://camo.githubusercontent.com/08ba1e39ba8b1ea78b5edae102d80c233c3da90fcbb88ac43493c20945ae6729/687474703a2f2f696d672e736869656c64732e696f2f62616467652f70617970616c2d646f6e6174652d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6MB5M2SQLP636 "Keep me off the streets")

PHP library for [two-factor (or multi-factor) authentication](http://en.wikipedia.org/wiki/Multi-factor_authentication) using [TOTP](http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) and [QR-codes](http://en.wikipedia.org/wiki/QR_code). Inspired by, based on but most importantly an *improvement* on '[PHPGangsta/GoogleAuthenticator](https://github.com/PHPGangsta/GoogleAuthenticator)'. There's a [.Net implementation](https://github.com/RobThree/TwoFactorAuth.Net) of this library as well.

[![](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/multifactorauthforeveryone.png)](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/multifactorauthforeveryone.png)

Requirements
------------

[](#requirements)

- Requires PHP version &gt;=8.2

Optionally, you may need:

- [sockets](https://www.php.net/manual/en/book.sockets.php) if you are using `NTPTimeProvider`
- [endroid/qr-code](https://github.com/endroid/qr-code) if using `EndroidQrCodeProvider` or `EndroidQrCodeWithLogoProvider`.
- [bacon/bacon-qr-code](https://github.com/Bacon/BaconQrCode) if using `BaconQrCodeProvider`.
- [php-curl library](http://php.net/manual/en/book.curl.php) when using an external QR Code provider such as `QRServerProvider`, `ImageChartsQRCodeProvider`, `QRicketProvider` or any other custom provider connecting to an external service.

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

[](#installation)

The best way of installing this library is with composer:

`php composer.phar require robthree/twofactorauth`

Usage
-----

[](#usage)

For a quick start, have a look at the [getting started](https://robthree.github.io/TwoFactorAuth/getting-started.html) page or try out the [demo](demo/demo.php).

If you need more in-depth information about the configuration available then you can read through the rest of [documentation](https://robthree.github.io/TwoFactorAuth).

Integrations
------------

[](#integrations)

- [CakePHP plugin](https://github.com/andrej-griniuk/cakephp-two-factor-auth)
- [CI4-Auth: a user, group, role and permission management library for Codeigniter 4](https://github.com/glewe/ci4-auth)

License
-------

[](#license)

Licensed under MIT license. See [LICENSE](./LICENSE) for details.

[Logo / icon](http://www.iconmay.com/Simple/Travel_and_Tourism_Part_2/luggage_lock_safety_baggage_keys_cylinder_lock_hotel_travel_tourism_luggage_lock_icon_465) under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication ([Archived page](http://riii.nl/tm7ap))

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance75

Regular maintenance activity

Popularity71

Solid adoption and visibility

Community48

Growing community involvement

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 51% 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 ~164 days

Recently: every ~195 days

Total

25

Last Release

133d ago

Major Versions

1.8.2 → v2.0.02023-02-25

v2.1.0 → v3.0.02024-05-27

PHP version history (4 changes)1.0PHP &gt;=5.3.0

1.7.0PHP &gt;=5.6.0

v2.0.0PHP &gt;=8.1.0

v3.0.0PHP &gt;=8.2.0

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/fca2ffc81ebd50445c0a05338ba2dacc6d2ee8f483b05664ed712eb8716a74cb?d=identicon)[willpower232](/maintainers/willpower232)

---

Top Contributors

[![RobThree](https://avatars.githubusercontent.com/u/607888?v=4)](https://github.com/RobThree "RobThree (201 commits)")[![NicolasCARPi](https://avatars.githubusercontent.com/u/3043706?v=4)](https://github.com/NicolasCARPi "NicolasCARPi (65 commits)")[![willpower232](https://avatars.githubusercontent.com/u/1619102?v=4)](https://github.com/willpower232 "willpower232 (51 commits)")[![xHeaven](https://avatars.githubusercontent.com/u/14284867?v=4)](https://github.com/xHeaven "xHeaven (31 commits)")[![MasterOdin](https://avatars.githubusercontent.com/u/1845314?v=4)](https://github.com/MasterOdin "MasterOdin (9 commits)")[![modelrailroader](https://avatars.githubusercontent.com/u/96944229?v=4)](https://github.com/modelrailroader "modelrailroader (7 commits)")[![Mattie112](https://avatars.githubusercontent.com/u/662896?v=4)](https://github.com/Mattie112 "Mattie112 (6 commits)")[![igorsantos07](https://avatars.githubusercontent.com/u/532299?v=4)](https://github.com/igorsantos07 "igorsantos07 (5 commits)")[![fman42](https://avatars.githubusercontent.com/u/46138641?v=4)](https://github.com/fman42 "fman42 (5 commits)")[![brainfoolong](https://avatars.githubusercontent.com/u/1684236?v=4)](https://github.com/brainfoolong "brainfoolong (2 commits)")[![anvyst](https://avatars.githubusercontent.com/u/227261?v=4)](https://github.com/anvyst "anvyst (2 commits)")[![YellowMaker](https://avatars.githubusercontent.com/u/138113597?v=4)](https://github.com/YellowMaker "YellowMaker (1 commits)")[![cedric-anne](https://avatars.githubusercontent.com/u/33253653?v=4)](https://github.com/cedric-anne "cedric-anne (1 commits)")[![cliffordvickrey](https://avatars.githubusercontent.com/u/25918827?v=4)](https://github.com/cliffordvickrey "cliffordvickrey (1 commits)")[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (1 commits)")[![givanz](https://avatars.githubusercontent.com/u/302738?v=4)](https://github.com/givanz "givanz (1 commits)")[![JonathanTru](https://avatars.githubusercontent.com/u/20085132?v=4)](https://github.com/JonathanTru "JonathanTru (1 commits)")[![RMEngels](https://avatars.githubusercontent.com/u/16747379?v=4)](https://github.com/RMEngels "RMEngels (1 commits)")[![SavageCore](https://avatars.githubusercontent.com/u/171312?v=4)](https://github.com/SavageCore "SavageCore (1 commits)")[![thomascorthals](https://avatars.githubusercontent.com/u/12425704?v=4)](https://github.com/thomascorthals "thomascorthals (1 commits)")

---

Tags

multi-factorphpqrcodesecuritytotptwo-factortwofactorauthphpAuthenticationTwo Factor AuthenticationMFAauthyauthenticatortfaMulti Factor Authentication

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/robthree-twofactorauth/health.svg)

```
[![Health](https://phpackages.com/badges/robthree-twofactorauth/health.svg)](https://phpackages.com/packages/robthree-twofactorauth)
```

###  Alternatives

[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)[paragonie/multi-factor

Vendor-agnostic two-factor authentication library

142195.5k2](/packages/paragonie-multi-factor)[chillerlan/php-authenticator

A generator for counter- and time based 2-factor authentication codes (Google Authenticator). PHP 8.2+

58119.1k2](/packages/chillerlan-php-authenticator)[awes-io/auth

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

3826.7k1](/packages/awes-io-auth)[remotemerge/totp-php

Lightweight, fast, and secure TOTP (2FA) authentication library for PHP — battle tested, dependency free, and ready for enterprise integration.

2010.2k](/packages/remotemerge-totp-php)

PHPackages © 2026

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