PHPackages                             romaltandel/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. romaltandel/otp-generator

ActiveLibrary

romaltandel/otp-generator
=========================

OTP Generator and Validator for Laravel Applications

080PHP

Since Jun 5Pushed 2y agoCompare

[ Source](https://github.com/romaltandel/otp-generator)[ Packagist](https://packagist.org/packages/romaltandel/otp-generator)[ RSS](/packages/romaltandel-otp-generator/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (1)Used By (0)

OTP Generator and Validator for Laravel Applications
====================================================

[](#otp-generator-and-validator-for-laravel-applications)

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

[](#installation)

You can install the package via composer:

```
composer require romaltandel/otp-generator dev-master@dev
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="RomalTandel\Otp\OtpServiceProvider" --tag="migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="RomalTandel\Otp\OtpServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

```
use RomalTandel\Otp\Otp;
.
.
$otp =  Otp::generate($identifier);
.
$verify = Otp::validate($identifier, $otp->token);
// example response
{
  "status": true
  "message": "OTP is valid"
}

// to get an expiredAt time
$expires = Otp::expiredAt($identifier);

// example response
{
+"status": true
+"expired_at": Illuminate\Support\Carbon @1611895244^ {
  ....
  #dumpLocale: null
  date: 2021-01-29 04:40:44.0 UTC (+00:00)
}
```

You have control to update the setting at otp-generator.php config file but you control while generating also

Advance Usage
-------------

[](#advance-usage)

```
use RomalTandel\Otp\Otp;
.
.
$otp =  Otp::setValidity(30)  // otp validity time in mins
      ->setLength(4)  // Lenght of the generated otp
      ->setMaximumOtpsAllowed(10) // Number of times allowed to regenerate otps
      ->setOnlyDigits(false)  // generated otp contains mixed characters ex:ad2312
      ->setUseSameToken(true) // if you re-generate OTP, you will get same token
      ->generate($identifier);
.
$verify = Otp::setAllowedAttempts(10) // number of times they can allow to attempt with wrong token
    ->validate($identifier, $otp->token);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [RomalTandel](https://github.com/romaltandel)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

16

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/c60226de139122a5ccac4aac48f1af70e3e060dd136371584d3cb54d574aebd7?d=identicon)[romal.tandel@thebilions.com](/maintainers/romal.tandel@thebilions.com)

---

Top Contributors

[![seshac](https://avatars.githubusercontent.com/u/22927513?v=4)](https://github.com/seshac "seshac (21 commits)")[![romaltandel](https://avatars.githubusercontent.com/u/121539015?v=4)](https://github.com/romaltandel "romaltandel (4 commits)")[![rakeshlanjewar](https://avatars.githubusercontent.com/u/36743306?v=4)](https://github.com/rakeshlanjewar "rakeshlanjewar (3 commits)")[![DeveloperBilions](https://avatars.githubusercontent.com/u/88443848?v=4)](https://github.com/DeveloperBilions "DeveloperBilions (2 commits)")[![sesha008](https://avatars.githubusercontent.com/u/35944087?v=4)](https://github.com/sesha008 "sesha008 (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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