PHPackages                             clarity-tech/laravel-otp-generator - 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. clarity-tech/laravel-otp-generator

ActiveLibrary

clarity-tech/laravel-otp-generator
==================================

a lightweight implementation of generating OTP and validating backed by Cache Storage for Laravel

v1.0.0-rc(3y ago)140[3 PRs](https://github.com/clarity-tech/laravel-otp-generator/pulls)MITPHPPHP ^8.1

Since Jul 31Pushed 3y ago1 watchersCompare

[ Source](https://github.com/clarity-tech/laravel-otp-generator)[ Packagist](https://packagist.org/packages/clarity-tech/laravel-otp-generator)[ Docs](https://github.com/clarity-tech/laravel-otp-generator)[ RSS](/packages/clarity-tech-laravel-otp-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (5)Used By (0)

a lightweight implementation of generating OTP and validating backed by Cache Storage for Laravel
=================================================================================================

[](#a-lightweight-implementation-of-generating-otp-and-validating-backed-by-cache-storage-for-laravel)

When you use Redis or any Cache driver it will self destruct things

[![Latest Version on Packagist](https://camo.githubusercontent.com/508f3de49721daecedb02f768b2da6f40b39352c1b2a023436312461110952df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c61726974792d746563682f6c61726176656c2d6f74702d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clarity-tech/laravel-otp-generator)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1ef3e035e816ffa1230ac33ff3098a7ec4227e99b3c98ac5087f8978b5105489/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636c61726974792d746563682f6c61726176656c2d6f74702d67656e657261746f722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/clarity-tech/laravel-otp-generator/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a7ae4eefe5b9df23bde6adb15b3b6bcefb327774b99ebd8c1f081095f1c53f60/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f636c61726974792d746563682f6c61726176656c2d6f74702d67656e657261746f722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/clarity-tech/laravel-otp-generator/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/77b2382fe8f369533e72ce1f8ca122d74436354da2ef4209f668974419143eaf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c61726974792d746563682f6c61726176656c2d6f74702d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/clarity-tech/laravel-otp-generator)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Support us
----------

[](#support-us)

We invest a lot of resources into creating [best in class open source packages](https://claritytech.io). You can support us by [buying one of our paid products](https://claritytech.io).

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

[](#installation)

You can install the package via composer:

```
composer require clarity-tech/laravel-otp-generator
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-otp-generator-config"
```

This is the contents of the published config file:

```
// config for ClarityTech/LaravelOtpGenerator
return [
    'debug' => false,
    'expiry' => env('OTP_EXPIRY', 15 * 60),
    'length' => env('OTP_LENGTH', 6),
];
```

Usage
-----

[](#usage)

```
use ClarityTech\LaravelOtpGenerator\Facades\AugmentedOTP;

$otp     =  AugmentedOTP::generateWithKey(9706353416);

$isValid =  AugmentedOTP::withKey(9706353416)->validate(123456);

$isValid =  AugmentedOTP::withKey(9706353416)->verify(123456);//does not trigger exception
```

The validate methods throws two exceptions based on which you can handle in your use case and modify the response to give for the user output as needed

```
use ClarityTech\LaravelOtpGenerator\Exceptions\OTPExpiredException;
use ClarityTech\LaravelOtpGenerator\Exceptions\OTPInvalidException;
```

And when you have request context available you can pass that too for more secure hash key generation internally which locks the OTP to be valid for that session / IP address only

```
$instance = AugmentedOTP::fromRequest(Request $request, string $mobileNo);

$otp = $instance->generate();

$otp = $instance->validate(123456);
```

you can determine whether provide code is valid or not

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Manash Jyoti Sonowal](https://github.com/msonowal)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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

1382d ago

### Community

Maintainers

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

---

Top Contributors

[![msonowal](https://avatars.githubusercontent.com/u/6334484?v=4)](https://github.com/msonowal "msonowal (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

laravelotp-generatorotp-verificationsmslaravelmsonowallaravel-otp-generatorclarity-techAugmentedOTP

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/clarity-tech-laravel-otp-generator/health.svg)

```
[![Health](https://phpackages.com/badges/clarity-tech-laravel-otp-generator/health.svg)](https://phpackages.com/packages/clarity-tech-laravel-otp-generator)
```

###  Alternatives

[spatie/laravel-site-search

A site search engine

300129.1k](/packages/spatie-laravel-site-search)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-rdap

Perform RDAP queries in a Laravel app

72108.3k2](/packages/spatie-laravel-rdap)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4719.6k5](/packages/ralphjsmit-laravel-glide)

PHPackages © 2026

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