PHPackages                             spomky-labs/otphp - 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. spomky-labs/otphp

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

spomky-labs/otphp
=================

A PHP library for generating one time passwords according to RFC 4226 (HOTP Algorithm) and the RFC 6238 (TOTP Algorithm) and compatible with Google Authenticator

11.4.2(3mo ago)1.5k46.1M—5.9%160[1 issues](https://github.com/Spomky-Labs/otphp/issues)[3 PRs](https://github.com/Spomky-Labs/otphp/pulls)20MITPHPPHP &gt;=8.1CI passing

Since Feb 24Pushed 2w ago37 watchersCompare

[ Source](https://github.com/Spomky-Labs/otphp)[ Packagist](https://packagist.org/packages/spomky-labs/otphp)[ Docs](https://github.com/Spomky-Labs/otphp)[ GitHub Sponsors](https://github.com/Spomky)[ Patreon](https://www.patreon.com/FlorentMorselli)[ RSS](/packages/spomky-labs-otphp/feed)WikiDiscussions 11.5.x Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (77)Used By (20)

TOTP / HOTP library in PHP
==========================

[](#totp--hotp-library-in-php)

[![Build Status](https://github.com/spomky-labs/otphp/workflows/Integrate/badge.svg)](https://github.com/spomky-labs/otphp/workflows/Integrate/badge.svg)[![Build Status](https://github.com/spomky-labs/otphp/workflows/Infection/badge.svg)](https://github.com/spomky-labs/otphp/workflows/Infection/badge.svg)

[![Latest Stable Version](https://camo.githubusercontent.com/c55ac4699452b2919e4cfcc8175a4e8efc802cb3521426e9091d14f917a918a1/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f762f737461626c652e706e67)](https://packagist.org/packages/spomky-labs/otphp)[![Total Downloads](https://camo.githubusercontent.com/951788b8d4efe1851090ce79da240c41699ec8a8cc7e955b7fdf73052baa5414/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f646f776e6c6f6164732e706e67)](https://packagist.org/packages/spomky-labs/otphp)[![Latest Unstable Version](https://camo.githubusercontent.com/6c0b26e3f444867f987569cff21f5f33b2e7eed090a433ea39660bd8abad3239/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f762f756e737461626c652e706e67)](https://packagist.org/packages/spomky-labs/otphp)[![License](https://camo.githubusercontent.com/9a4149052c508a6bc4792a9a6a13d263a1e29944fdfb223a50ac48038c3f2bd6/68747470733a2f2f706f7365722e707567782e6f72672f73706f6d6b792d6c6162732f6f747068702f6c6963656e73652e706e67)](https://packagist.org/packages/spomky-labs/otphp)

A php library for generating one-time passwords according to [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226) (HOTP Algorithm) and [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238) (TOTP Algorithm)

This library is compatible with Google Authenticator apps available for Android and iPhone. It is also compatible with other applications such as [FreeOTP](https://play.google.com/store/apps/details?id=org.fedorahosted.freeotp) for example.

Documentation
=============

[](#documentation)

The documentation of this project is available in the [*doc* folder](doc/index.md).

Support
=======

[](#support)

I bring solutions to your problems and answer your questions.

If you really love that project, and the work I have done or if you want I prioritize your issues, then you can help me out for a couple of 🍻 or more!

[Become a sponsor](https://github.com/sponsors/Spomky)

Or

[![Become a Patreon](https://camo.githubusercontent.com/ef7b855018f1f680eeba6fd1ac470b9c1971ef883b2f4b9fcf41034274510e3f/68747470733a2f2f63352e70617472656f6e2e636f6d2f65787465726e616c2f6c6f676f2f6265636f6d655f615f706174726f6e5f627574746f6e2e706e67)](https://www.patreon.com/FlorentMorselli)

Contributing
------------

[](#contributing)

Requests for new features, bug fixes and all other ideas to make this project useful are welcome.

Please report all issues in [the repository bug tracker](https://github.com/Spomky-Labs/otphp/issues).

Also make sure to [follow these best practices](.github/CONTRIBUTING.md).

Licence
-------

[](#licence)

This software is release under the [MIT licence](LICENSE).

###  Health Score

78

—

ExcellentBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity76

Solid adoption and visibility

Community50

Growing community involvement

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 76.3% 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 ~64 days

Recently: every ~13 days

Total

69

Last Release

85d ago

Major Versions

v8.3.1 → v9.0.22017-07-24

v8.3.2 → v9.0.32017-11-23

v8.3.x-dev → v9.1.12018-10-26

v9.1.4 → v10.0.02019-07-30

v10.0.3 → v11.0.02022-06-24

PHP version history (9 changes)v1.0.0-stablePHP &gt;=5.3.2

v6.0.0PHP &gt;=5.6

v6.0.3PHP &gt;=5.5.9

v7.0.3PHP &gt;=5.5

v8.0.0PHP ^5.5|^7.0

v9.0.0-alpha1PHP ^7.1

v10.0.0PHP ^7.2|^8.0

v11.0.0PHP ^8.1

11.3.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![Spomky](https://avatars.githubusercontent.com/u/1091072?v=4)](https://github.com/Spomky "Spomky (203 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (25 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (8 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (4 commits)")[![exussum12](https://avatars.githubusercontent.com/u/1102850?v=4)](https://github.com/exussum12 "exussum12 (2 commits)")[![fefas](https://avatars.githubusercontent.com/u/6557756?v=4)](https://github.com/fefas "fefas (2 commits)")[![noplanman](https://avatars.githubusercontent.com/u/9423417?v=4)](https://github.com/noplanman "noplanman (2 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (2 commits)")[![johnny-y-wang](https://avatars.githubusercontent.com/u/4994102?v=4)](https://github.com/johnny-y-wang "johnny-y-wang (1 commits)")[![kix](https://avatars.githubusercontent.com/u/345754?v=4)](https://github.com/kix "kix (1 commits)")[![kw-pr](https://avatars.githubusercontent.com/u/9133572?v=4)](https://github.com/kw-pr "kw-pr (1 commits)")[![leandro-lugaresi](https://avatars.githubusercontent.com/u/858713?v=4)](https://github.com/leandro-lugaresi "leandro-lugaresi (1 commits)")[![pkly](https://avatars.githubusercontent.com/u/17160364?v=4)](https://github.com/pkly "pkly (1 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (1 commits)")[![ssx](https://avatars.githubusercontent.com/u/254889?v=4)](https://github.com/ssx "ssx (1 commits)")[![tomme87](https://avatars.githubusercontent.com/u/9094256?v=4)](https://github.com/tomme87 "tomme87 (1 commits)")[![yookoala](https://avatars.githubusercontent.com/u/91274?v=4)](https://github.com/yookoala "yookoala (1 commits)")[![Aadeesh11](https://avatars.githubusercontent.com/u/66922161?v=4)](https://github.com/Aadeesh11 "Aadeesh11 (1 commits)")[![ziegenberg](https://avatars.githubusercontent.com/u/856916?v=4)](https://github.com/ziegenberg "ziegenberg (1 commits)")[![anthonyryan1](https://avatars.githubusercontent.com/u/543852?v=4)](https://github.com/anthonyryan1 "anthonyryan1 (1 commits)")

---

Tags

hotpotpphprfc-4226rfc-6238rfc4226rfc6238totpgoogle authenticatorotphotptotpRFC 6238RFC 4226FreeOTP

### Embed Badge

![Health badge](/badges/spomky-labs-otphp/health.svg)

```
[![Health](https://phpackages.com/badges/spomky-labs-otphp/health.svg)](https://phpackages.com/packages/spomky-labs-otphp)
```

###  Alternatives

[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1225.3M72](/packages/web-auth-webauthn-lib)[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)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)[pedrosancao/php-otp

PHP implementation of HMAC-based one-time password algorithm according to RFC 4226 and RFC 6238 compatible with Google Authenticator

1863.8k](/packages/pedrosancao-php-otp)[paragonie/multi-factor

Vendor-agnostic two-factor authentication library

142195.5k2](/packages/paragonie-multi-factor)[2amigos/2fa-library

2 Factor Authentication (2FA) library

34367.1k7](/packages/2amigos-2fa-library)

PHPackages © 2026

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