PHPackages                             esakian/yamato - 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. esakian/yamato

ActiveLibrary

esakian/yamato
==============

A package for OTP authentication with Redis rate limiting.

v1.0.0(1y ago)13MITPHPPHP &gt;=7.4

Since Oct 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/esa-kian/yamato)[ Packagist](https://packagist.org/packages/esakian/yamato)[ RSS](/packages/esakian-yamato/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Yamato
======

[](#yamato)

**Yamato** is a PHP package for generating and validating One-Time Passwords (OTPs) with Redis rate limiting. It’s ideal for adding secure, time-limited authentication flows to your PHP application.

Features
--------

[](#features)

- Generates and validates OTPs.
- Enforces rate limiting using Redis to prevent OTP abuse.
- Configurable OTP expiration time and rate limits.

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

[](#installation)

Install Yamato via Composer:

```
composer require esakian/yamato
```

Make sure to install Predis or any other Redis client compatible with your PHP setup, as it’s required for rate limiting.

Usage
-----

[](#usage)

1. **Setup**Initialize a Redis client and pass it to the package:

```
require 'vendor/autoload.php';

use Predis\Client;
use YourVendor\OTPAuth\OTPAuth;
use YourVendor\OTPAuth\RedisRateLimiter;

// Initialize Redis client
$redis = new Client();

// Configure Redis rate limiter (5 attempts per minute)
$rateLimiter = new RedisRateLimiter($redis, 5, 60);

// Configure OTP authentication with a 5-minute OTP expiration
$otpAuth = new OTPAuth($rateLimiter, 300);
```

2. **Generating an OTP**To generate an OTP for a given identifier (e.g., an email or user ID):

```
try {
    $identifier = 'user@example.com';
    $otp = $otpAuth->generateOTP($identifier);
    echo "Your OTP is: {$otp}\n";
} catch (Exception $e) {
    echo $e->getMessage(); // Handle rate limit exceptions
}
```

3. **Validating an OTP**To validate an OTP provided by the user:

```
$isValid = $otpAuth->validateOTP('user@example.com', $otp);
if ($isValid) {
    echo "OTP is valid.\n";
} else {
    echo "OTP is invalid or expired.\n";
}
```

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

[](#configuration)

You can customize the OTP expiration time and rate limit as shown below:

```
// RedisRateLimiter configuration
$rateLimit = 5; // maximum 5 attempts
$rateLimitPeriod = 60; // within 60 seconds
$rateLimiter = new RedisRateLimiter($redis, $rateLimit, $rateLimitPeriod);

// OTPAuth configuration
$otpExpiration = 300; // OTP expires in 5 minutes
$otpAuth = new OTPAuth($rateLimiter, $otpExpiration);
```

Unit Tests
----------

[](#unit-tests)

To run the unit tests:

1. Install development dependencies:

```
composer install --dev
```

2. Run PHPUnit:

```
vendor/bin/phpunit
```

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

[](#requirements)

- PHP &gt;= 7.4
- Redis server
- Predis (or equivalent Redis client)

License
-------

[](#license)

This package is open-source software licensed under the MIT license.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

558d ago

### Community

Maintainers

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

---

Top Contributors

[![esa-kian](https://avatars.githubusercontent.com/u/19409516?v=4)](https://github.com/esa-kian "esa-kian (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/esakian-yamato/health.svg)

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

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[teamtnt/tntsearch

A fully featured full text search engine written in PHP

3.2k3.0M28](/packages/teamtnt-tntsearch)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[pdffiller/qless-php

PHP Bindings for qless

29113.2k1](/packages/pdffiller-qless-php)[concrete5/core

Concrete core subtree split

19159.3k48](/packages/concrete5-core)

PHPackages © 2026

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