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

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

triverla/laravel-otp
====================

Laravel package for OTP Generation and Validation

v1.0.0(2y ago)13MITPHPPHP ^7.4|^8.0

Since Aug 18Pushed 2y ago1 watchersCompare

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

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

Laravel OTP Generator with Mail and SMS Notification
====================================================

[](#laravel-otp-generator-with-mail-and-sms-notification)

This package is for easy setup for OTP validation process. No database required.

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

[](#installation)

NB: This package only supports 7.4+

Via Composer

```
composer require triverla/laravel-otp
```

### Add Service Provider &amp; Facade

[](#add-service-provider--facade)

#### For Laravel 5.5+

[](#for-laravel-55)

Once the package is added, the service provider and facade will be auto discovered.

#### For Older versions of Laravel

[](#for-older-versions-of-laravel)

Add the ServiceProvider to the providers array in `config/app.php`:

```
Triverla\LaravelOtp\OtpServiceProvider::class
```

Add the Facade to the aliases array in `config/app.php`:

```
'Otp' => Triverla\LaravelOtp\OtpServiceProvider::class
```

Publish Config
--------------

[](#publish-config)

Once done, publish the config to your config folder using:

```
php artisan vendor:publish --provider="Triverla\LaravelOtp\OtpServiceProvider"

```

This command will create a `config/otp.php` file.

Env Variables
-------------

[](#env-variables)

Add the following Key-Value pair to the `.env` file in the Laravel application

```
OTP_LENGTH=6
OTP_TIMEOUT=15
OTP_MAILABLE_CLASS=Triverla\LaravelOtp\Notifications\NewOtpMail::class
OTP_SMS_CLASS=Triverla\LaravelOtp\Notifications\NewOtpSms::class
OTP_TRANSPORT_EMAIL=true
OTP_TRANSPORT_SMS=false
```

### Custom Notification Classes

[](#custom-notification-classes)

You can use custom classes for your Mail and SMS notifications. You can either add it via `.env` or in `config/otp.php`

Usage
-----

[](#usage)

Import the facade class:

```
use Triverla\LaravelOtp\Facades\Otp;
```

or

```
otp()
```

**Generate an OTP:**

```
$otp = Otp::generate($unique_secret); // string
$otp = otp()->generate($unique_secret); // string
```

**Verify an OTP:**

```
$otp = Otp::generate($unique_secret);

$check = otp()->verify($otp, $unique_secret); // bool
```

**Regenerate an OTP:**This can be used to resend same or different OTP

```
$otp = otp()->regenerate($unique_secret, false); // true to change OTP and false to use same OTP
```

**Generate an OTP &amp; Send sms or mail notification to recipient:**

```
use Triverla\LaravelOtp\Helpers\OtpNotificationRequest;

$sendOtp = Otp::notify(new OtpNotificationRequest(otp()->generate($unique_secret), $emailAddress, $mobileNumber)); // bool

// $emailAddress and $mobileNumber are nullable. You can use both or either.
```

### Contributing

[](#contributing)

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

### Bugs &amp; Issues

[](#bugs--issues)

If you notice any bug or issues with this package kindly create and issues here [ISSUES](https://github.com/triverla/laravel-otp/issues)

### Security

[](#security)

If you discover any security related issues, please email .

How can I thank you?
--------------------

[](#how-can-i-thank-you)

Why not star the github repo and share the link for this repository on Twitter or other social platforms.

Don't forget to [follow me on twitter](https://twitter.com/benaiah_yusuf)!

Thanks! Benaiah Yusuf

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

1049d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5122113?v=4)[Benaiah Yusuf ](/maintainers/triverla)[@Triverla](https://github.com/Triverla)

---

Top Contributors

[![Triverla](https://avatars.githubusercontent.com/u/5122113?v=4)](https://github.com/Triverla "Triverla (8 commits)")

---

Tags

otpone-time-passwordlaravel otpphp otpotp generatorotp verificationlaravel-one-time-passwordtriverla

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

244672.1k1](/packages/tzsk-otp)[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)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

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

This package provides convenient methods for sending and validating OTP notifications to users for authentication.

21227.6k](/packages/fouladgar-laravel-otp)

PHPackages © 2026

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