PHPackages                             saddamsegwitz/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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. saddamsegwitz/otp-generator

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

saddamsegwitz/otp-generator
===========================

OTP Generator and Validator for Laravel Applications

1.0.0(4y ago)04MITPHPPHP ^7.3|7.4|^8.0

Since Mar 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/saddamsegwitz/laravel-otp)[ Packagist](https://packagist.org/packages/saddamsegwitz/otp-generator)[ Docs](https://github.com/saddamsegwitz/otp-generator)[ GitHub Sponsors](https://github.com/Segwitz)[ RSS](/packages/saddamsegwitz-otp-generator/feed)WikiDiscussions master Synced 1mo ago

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

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/4e31f34fc237afa5599c711697b7c51c3a22837bef30836d336b0b2a7678c1bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f5365677769747a2f6f74702d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Segwitz/otp-generator)[![GitHub Tests Action Status](https://github.com/Segwitz/otp-generator/workflows/Tests/badge.svg)](https://github.com/Segwitz/otp-generator/workflows/Tests/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/bacd5ebd9a89bf0aef9e70be949479a8ffd54ce94b2922ef77abc8053ef1ab82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f5365677769747a2f6f74702d67656e657261746f722e7376673f3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Segwitz/laravel-shiprocket-api)

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

[](#installation)

You can install the package via composer:

```
composer require Segwitz/otp-generator
```

You can publish and run the migrations with:

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

You can publish the config file with:

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

Usage
-----

[](#usage)

```
use Segwitz\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 Segwitz\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)

- [sesha](https://github.com/Segwitz)
- [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

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

1511d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21952147bdc95b6a9bc06629802dce6d881ea48d70cecbf2ce710651504ff406?d=identicon)[saddamsegwitz](/maintainers/saddamsegwitz)

---

Top Contributors

[![saddamsegwitz](https://avatars.githubusercontent.com/u/94036924?v=4)](https://github.com/saddamsegwitz "saddamsegwitz (2 commits)")

---

Tags

laravelotp generatorsaddamsegwitz

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[imdhemy/laravel-purchases

The top-notch Laravel receipt validator.

3831.1M2](/packages/imdhemy-laravel-purchases)[martbock/laravel-diceware

Diceware Passphrase Generator for Laravel

3264.7k](/packages/martbock-laravel-diceware)[orchestra/auth

Auth Component for Orchestra Platform

24108.5k3](/packages/orchestra-auth)[ingria/laravel-x509-auth

Laravel 5 Client Certificate auth middleware

375.6k](/packages/ingria-laravel-x509-auth)

PHPackages © 2026

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