PHPackages                             signaturetech/laravel-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. [Mail &amp; Notifications](/categories/mail)
4. /
5. signaturetech/laravel-otp

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

signaturetech/laravel-otp
=========================

A package to generate and manage otp

1.0.5(11mo ago)181.2k2MITPHPPHP &gt;=8.0

Since Mar 17Pushed 11mo agoCompare

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

READMEChangelog (6)Dependencies (1)Versions (8)Used By (0)

[![Laravel](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)

LaravelOtp : generate OTP and Validate OTP
==========================================

[](#laravelotp--generate-otp-and-validate-otp)

---

[![GitHub](https://camo.githubusercontent.com/5ed1e3c4e8f37ef7068c73ef6aa14c5cbe099ae3e3a5a51325364840a3d80a8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7369676e6174757265746563682f6c61726176656c2d6f7470)](https://camo.githubusercontent.com/5ed1e3c4e8f37ef7068c73ef6aa14c5cbe099ae3e3a5a51325364840a3d80a8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7369676e6174757265746563682f6c61726176656c2d6f7470)[![Packagist Downloads](https://camo.githubusercontent.com/6567867874ac8852fb7b7eee344e484b104945a0515c2cafa828858a32691938/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369676e6174757265746563682f6c61726176656c2d6f7470)](https://camo.githubusercontent.com/6567867874ac8852fb7b7eee344e484b104945a0515c2cafa828858a32691938/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369676e6174757265746563682f6c61726176656c2d6f7470)

Table of contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Todo](#todo)
- [License](#license)

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

[](#introduction)

`LaravelOtp` is a [Laravel](https://laravel.com/) package, designed to generate OTP and Validate OTP using simple steps. This packages will show all OTP history.

Todo
----

[](#todo)

- Generate OTP
- Verify OTP
- Methods
- OTP Lists
- Test Cases

Features
--------

[](#features)

- Generate OTP
- Verify OTP
- Get the User OTP List
- Generate custom lenth, expiry and formate OTP

Installation &amp; Configuration
--------------------------------

[](#installation--configuration)

You can install this package via composer using:

```
composer require signaturetech/laravel-otp

```

Next run the command below to setup api-response.config file, you can set your configuration.

```
php artisan vendor:publish --tag=otp-config

```

Now add the `use SignatureTech\LaravelOtp\Traits\Otpable` trait to your model.

```
use SignatureTech\LaravelOtp\Traits\Otpable;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable, Otpable;
}

```

### Generate OTP

[](#generate-otp)

Please use below code to generate otp:

1. Get User Details

```
use App\Models\User;

$user = User::first();

```

2. Create Otp Instance

```
use SignatureTech\LaravelOtp\Otp;

$otp = Otp::for($user->email)->generate();

```

**Note:** You can use email/mobile/phone number to generate otp Just pass the detail using `for` method.

**Note:** You can use more method to setting otp all methods described in `methods` section.

3. Attach Otp with user

```
$userOtp = $user->createOtp($otp);

$otp = $user->otp;

```

### Verify OTP

[](#verify-otp)

You can verify otp by using below code:

1. Get the use details

```
use App\Models\User;

$user = User::first();

```

2. Get Otp Instance

```
use SignatureTech\LaravelOtp\Otp;

$otp = Otp::for($user->email)->getOtp();

```

3. Verify Otp

```
try {
    $user->verifyOtp($otp, $request->get('otp'));
} catch (OtpInvalidException $e) {
    return $e->getMessage;
} catch (OtpExpiredException $e) {
    return $e->getMessage;
}

```

### Create OTP without model

[](#create-otp-without-model)

You can also create otp without model using the following:

1. Create OTP

```
use SignatureTech\LaravelOtp\Otp;

$otp = Otp::for($user->email)->create();

```

**Note:** You can use email/mobile/phone number to generate otp Just pass the detail using `for` method.

**Note:** You can use more method to setting otp all methods described in `methods` section.

2. Verify Otp

```
try {
    $otp->verifyOtp($request->get('otp'));
} catch (OtpInvalidException $e) {
    return $e->getMessage;
} catch (OtpExpiredException $e) {
    return $e->getMessage;
}

```

Methods
-------

[](#methods)

1. Set length of otp

```
use SignatureTech\LaravelOtp\Otp;

// Set Length of OTP
$otp = Otp::for($user->email)->setLength(4)->generate();

```

**Note:** Default length is 6 digit and you can change the default digit to add the `OTP_LENGTH=4` in `.env` or `config/otp.php` file

2. Set Format (Available Format: alpha | alphanumeric | numeric)

```
use SignatureTech\LaravelOtp\Otp;

// Set Format (Available Format: alpha | alphanumeric | numeric)
$otp = Otp::for($user->email)->setFormat('numeric')->generate();

```

**Note:** Default format is numeric and you can change the default format to add the `OTP_FORMAT=4` in `.env` or `config/otp.php` file

2. Set Expiry (In minutes)

```
use SignatureTech\LaravelOtp\Otp;

// Set Format (Available Format: alpha | alphanumeric | numeric)
$otp = Otp::for($user->email)->setExpiry(20)->generate();

```

**Note:** Default expiry is 10 minutes and you can change this to add the `OTP_EXPIRY=20` in `.env` or `config/otp.php` file

License
-------

[](#license)

- Written and copyrighted ©2022 by Prem Chand Saini ()
- ResponseBuilder is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance52

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~90 days

Recently: every ~64 days

Total

6

Last Release

335d ago

### Community

Maintainers

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

---

Top Contributors

[![pcsaini](https://avatars.githubusercontent.com/u/10773104?v=4)](https://github.com/pcsaini "pcsaini (17 commits)")

---

Tags

laravelotpemailmobilelaravel otp

### Embed Badge

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

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

###  Alternatives

[synergitech/laravel-postal

This library integrates Postal with the standard Laravel mail framework.

38107.1k](/packages/synergitech-laravel-postal)[ferdous/laravel-otp-validate

Laravel package for OTP validation with built-in features like retry and resend mechanism. Built in max retry and max resend blocking. OTP/Security Code can be send over SMS or Email of your choice with user-defined template.

7124.4k](/packages/ferdous-laravel-otp-validate)

PHPackages © 2026

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