PHPackages                             prasanth-j/otpify - 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. prasanth-j/otpify

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

prasanth-j/otpify
=================

A secure, flexible OTP package for Laravel. Supports database and cache drivers, multiple purposes, hashed storage, events, and validation rules.

v2.0.0(yesterday)239MITPHPPHP ^8.1

Since Aug 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/prasanth-j/otpify)[ Packagist](https://packagist.org/packages/prasanth-j/otpify)[ Docs](https://github.com/prasanth-j/otpify)[ RSS](/packages/prasanth-j-otpify/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (13)Versions (8)Used By (0)

Laravel Otpify 🔑
================

[](#laravel-otpify-)

[![Build Status](https://camo.githubusercontent.com/7e83940173064b2b4e6a06f856203bc048e767ad969d170b97222735c06fbf79/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70726173616e74682d6a2f6f74706966792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/prasanth-j/otpify/build-status/master)[![Total Downloads](https://camo.githubusercontent.com/61b65334b1745f9968445b72ac23ef7fef74ce83bd8b7efeed7f72f6cc34e02e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726173616e74682d6a2f6f74706966792e737667)](https://packagist.org/packages/prasanth-j/otpify)[![Latest Version on Packagist](https://camo.githubusercontent.com/13df4db2cdc3936962dcf3081ed0a16fc57c6e1631c2354993fa1bcfbe786409/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726173616e74682d6a2f6f7470696679)](https://packagist.org/packages/prasanth-j/otpify)[![License: MIT](https://camo.githubusercontent.com/4cee3b0c35d9c4bb7d64c3ea0842daf10714208f10e24bddaaa48d319c845ed4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70726173616e74682d6a2f6f7470696679)](https://opensource.org/licenses/MIT)

Introduction
------------

[](#introduction)

Otpify is a Laravel package that provides a simple and elegant way to generate and validate one time passwords.

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

[](#installation)

You can install the package via composer:

```
composer require prasanth-j/otpify
```

You can run the migrations with:

```
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="otpify-config"
```

This is the contents of the published config file:

```
return [
    /**
     * The length of token.
     */
    'digits'    => 6,

    /**
     * The expiry time of token in minutes.
     */
    'validity'  => 15
];
```

Optionally, you can publish the migrations using

```
php artisan vendor:publish --tag="otpify-migrations"
```

Usage
-----

[](#usage)

### 1. Generate OTP

[](#1-generate-otp)

```
use PrasanthJ\Otpify\Facades\Otpify;

Otpify::generate(string $identifier, int $userId, string $otpType, int $digits, int $validity);
```

- `$identifier`: The identity (email or mobile) that will be tied to the OTP.
- `$userId (optional | default = null)`: The user id from user table.
- `$otpType (optional | default = null)`: The category of the OTP, like login, verification, etc.
- `$digits (optional | default = 6)`: The amount of digits to be generated, should be 4 to 8.
- `$validity (optional | default = 15)`: The validity period of the OTP in minutes.

#### Example

[](#example)

```
use PrasanthJ\Otpify\Facades\Otpify;

$otp = Otpify::generate('john@example.com', 2, 'verification', 6, 10);
```

This will generate a six digit OTP that will be valid for 10 minutes and the success response will be:

```
{
  "status": "success",
  "token": "535923",
  "message": "OTP genetated successfully"
}

```

### 2. Validate OTP

[](#2-validate-otp)

```
use PrasanthJ\Otpify\Facades\Otpify;

Otpify::validate(string $identifier, string $token, string $otpType);
```

- `$identifier`: The identity (email or mobile) that will be tied to the OTP.
- `$token`: The token tied to the identity.
- `$otpType (optional | default = null)`: The category of the OTP, like login, verification, etc.

#### Example

[](#example-1)

```
use PrasanthJ\Otpify\Facades\Otpify;

$otp = Otpify::generate('john@example.com', '535923', 'verification');
```

#### Responses

[](#responses)

**On Success**

```
{
  "status": "success",
  "message": "OTP is valid"
}

```

**Does not exist**

```
{
  "status": "error",
  "message": "OTP does not exist"
}

```

**On Error**

```
{
  "status": "warning",
  "message": "OTP invalid"
}

```

**Expired**

```
{
  "status": "error",
  "message": "OTP Expired"
}

```

**Already Verified**

```
{
  "status": "info",
  "message": "OTP already verified"
}

```

### Delete verified tokens

[](#delete-verified-tokens)

You can delete verified tokens by running the following artisan command:

```
php artisan otpify:clean
```

You can also add this artisan command to `app/Console/Kernel.php` to automatically clean on scheduled

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('otpify:clean')->daily();
}
```

Contribution
------------

[](#contribution)

If you find an issue with this package or you have any suggestions please help out.

License
-------

[](#license)

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

###  Health Score

36

↑

LowBetter than 79% of packages

Maintenance55

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~356 days

Total

5

Last Release

1d ago

Major Versions

v1.0.3 → v2.0.02026-07-02

PHP version history (5 changes)v1.0.0PHP ^7.4

v1.0.1PHP &gt;=5.4.0

v1.0.2PHP &gt;=7.4.0

v1.0.3PHP ^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/85541084b54c4232d09cfd2b861299f5b505e5ce991193521758323489be6c64?d=identicon)[prasanthjayakumar](/maintainers/prasanthjayakumar)

---

Top Contributors

[![prasanth-j](https://avatars.githubusercontent.com/u/29867996?v=4)](https://github.com/prasanth-j "prasanth-j (7 commits)")

---

Tags

laravellaravel-otplaravel-packageone-time-passwordotp-verificationotpifyone-time-passwordlaravel otpotp-validationotpify

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/prasanth-j-otpify/health.svg)

```
[![Health](https://phpackages.com/badges/prasanth-j-otpify/health.svg)](https://phpackages.com/packages/prasanth-j-otpify)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M130](/packages/laravel-pulse)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M145](/packages/laravel-cashier)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M193](/packages/laravel-ai)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M130](/packages/roots-acorn)

PHPackages © 2026

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