PHPackages                             creatvstudio/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. creatvstudio/laravel-otp

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

creatvstudio/laravel-otp
========================

A Laravel package that handles Time based OTP

v0.0.1(5y ago)026MITPHPPHP ^7.1

Since Jun 9Pushed 5y ago2 watchersCompare

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

READMEChangelogDependencies (4)Versions (5)Used By (0)

Laravel OTP
===========

[](#laravel-otp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d024e01e9e11626fe8be183ef3b3a9cdedaf4a9d32ff6dfc889167b36d57b6eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63726561747673747564696f2f6c61726176656c2d6f74702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creatvstudio/laravel-otp)[![Total Downloads](https://camo.githubusercontent.com/5f70f493892ab1ebad8e6633a3daabbaaf46b844852a37b8a59dcb0e3ec9486a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63726561747673747564696f2f6c61726176656c2d6f74702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creatvstudio/laravel-otp)

**This package is still in alpha stage.** A laravel package to implement timebased otp.

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

[](#installation)

You can install the package via composer:

```
composer require creatvstudio/laravel-otp
```

Publish package

```
php artisan vendor:publish --provider="CreatvStudio\Otp\OtpServiceProvider"
```

Run the migrations

```
php artisan migrate
```

Add to your `config/app.php`

```
aliases => [
    ...
    'Otp' => \CreatvStudio\Otp\Facades\Otp::class,
    ...
],
```

Set your mail settings from `.env` file

```
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
```

Publish config file using the following command:

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

Usage
-----

[](#usage)

Add trait to your User class

```
use CreatvStudio\Otp\HasOtp;

class User extends Authenticable {
    use Notifiable;
    use HasOtp;
}

// Generate an OTP
$otp = $user->getOtpCode();

// Verify an OTP
$user->verifyOtp($otp);
```

Protecting routes
-----------------

[](#protecting-routes)

Add the following codes to `$routeMiddleware` of `app/Http/Kernel.php`

```
protected $routeMiddleware = [
    ...
    'otp' => \CreatvStudio\Otp\Http\Middleware\CheckOtpSession::class,
]
```

Use to your `routes/web.php`

```
Otp::routes();

Route::middleware(['auth'])->group(function(){
    Route::get('otp-protected')->middleware('otp');
});
```

> Note: Default Laravel Authentication is required to make the otp routes work properly.

Customizing sending of OTP Code to Mail
---------------------------------------

[](#customizing-sending-of-otp-code-to-mail)

To customize the contents of email when sending OTP Code, just modify `./app/Notifications/SendOtpNotification.php`

> Note: Please refer to Official Laravel Documentation for [custom notifications](https://laravel.com/docs/7.x/notifications#custom-channels).

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Jeffrey Naval](https://github.com/creatvstudio)
- [Samuel Magana](https://github.com/maganasamuel)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.2% 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

2146d ago

### Community

Maintainers

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

---

Top Contributors

[![maganasamuel](https://avatars.githubusercontent.com/u/6646075?v=4)](https://github.com/maganasamuel "maganasamuel (51 commits)")[![JeffreyNaval](https://avatars.githubusercontent.com/u/720377?v=4)](https://github.com/JeffreyNaval "JeffreyNaval (2 commits)")

---

Tags

laravelotpcreatvstudio

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[fouladgar/laravel-otp

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

21426.5k](/packages/fouladgar-laravel-otp)[teckwei1993/laravel-otp

Laravel OTP generator and validation

5556.0k](/packages/teckwei1993-laravel-otp)

PHPackages © 2026

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