PHPackages                             phant/otp - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phant/otp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phant/otp
=========

Manage OTP easily

1.1(1y ago)04.5k↓68.3%MITPHPPHP &gt;=8.2

Since Sep 28Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/PhantPHP/otp)[ Packagist](https://packagist.org/packages/phant/otp)[ RSS](/packages/phant-otp/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

OTP
===

[](#otp)

Presentation
------------

[](#presentation)

The OTP service is designed to manage OTPs (One Time Passwords) that can be used for authentication, confirmation or any other validation requirement for a user.

Process :

1. The service generate an OTP and send it to the user,
2. The user receives the OTP,
3. The application retrieves the OTP from the user,
4. The application verifies the OTP with the service.

The OTP is sent to the user by your own OtpSender service (e-mail, SMS, etc.).

Technologies used
-----------------

[](#technologies-used)

- `PHP 8.2`
- `Composer` for dependencies management (PHP)

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

[](#installation)

`composer install`

Usage
-----

[](#usage)

### Config

[](#config)

```
use Phant\DataStructure\Key\Ssl as SslKey;
use Phant\Otp\Service\Request as Service;
use App\OtpRepository;
use App\OtpSender;

// Config

$otpRepository = new OtpRepository();
$otpSender = new OtpSender();
$sslKey = new SslKey($privateKey, $publicKey);

// Build service

$service = new Service(
	$otpRepository,
	$otpSender,
	$sslKey
);
```

### Request OTP

[](#request-otp)

```
// OTP context transmitted to sender
$payload = [
	'email' => 'willy@wonka.com',
];

$requestToken = $service->generate(
	$payload
);
```

### Verify OTP

[](#verify-otp)

```
use Phant\Error\NotCompliant;

// Request token obtained previously
$requestToken = '...';

// Obtain Otp from user
$otp = '123456';

try {
	$payload = $service->verify(
		$requestToken,
		$otp
	);
} catch (NotCompliant $e) {
	$numberOfAttemptsRemaining = $otpService->getNumberOfRemainingAttempts(
		$requestToken
	);
}
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance52

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Total

2

Last Release

516d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ce749176c74e4c4fd7bd457cdad471fd1e0e14092259e60e7330724ce622dce?d=identicon)[Phant](/maintainers/Phant)

---

Top Contributors

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

---

Tags

otp managerotp componentsimple otp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phant-otp/health.svg)

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

###  Alternatives

[t4web/composer-lock-parser

OOP reader of composer.lock file.

20200.4k8](/packages/t4web-composer-lock-parser)[uvdesk/automation-bundle

UVDesk Community Help desk Automation Bundle

2240.2k](/packages/uvdesk-automation-bundle)

PHPackages © 2026

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