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

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

dukstra/otp
===========

A Laravel package for generating, validating and handling OTPs

v1.1(4y ago)0357MITPHPPHP ^7.4|^8.0

Since Apr 20Pushed 4y ago1 watchersCompare

[ Source](https://github.com/dukstra/otp-generator)[ Packagist](https://packagist.org/packages/dukstra/otp)[ RSS](/packages/dukstra-otp/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (2)Dependencies (4)Versions (3)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 dukstra/otp
```

You can publish and run the migrations with:

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

You can publish the config file with:

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

Usage
-----

[](#usage)

```
use Dukstra\Otp\Otp;
.
.
$otp =  Otp::generate($identifier);
.
$verify = Otp::validateUsingIdentifier($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 can also control while generating.

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

[](#advance-usage)

```
use Dukstra\Otp\Otp;
.
.
$otp =  Otp::setValidity(30)  // otp validity time in mins
      ->setLength(4)  // Length 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
    ->validateUsingIdentifier($identifier, $otp->token);
```

Testing
-------

[](#testing)

```
composer test

```

Credits
-------

[](#credits)

- [sesha](https://github.com/seshac)

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~114 days

Total

2

Last Release

1740d ago

### Community

Maintainers

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

---

Top Contributors

[![evidencefrank](https://avatars.githubusercontent.com/u/45165183?v=4)](https://github.com/evidencefrank "evidencefrank (1 commits)")[![EvidenceMandizvidza](https://avatars.githubusercontent.com/u/64771774?v=4)](https://github.com/EvidenceMandizvidza "EvidenceMandizvidza (1 commits)")

---

Tags

laravelotp generatordukstra

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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