PHPackages                             nakanakaii/otp-service - 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. nakanakaii/otp-service

ActiveLibrary

nakanakaii/otp-service
======================

Reusable OTP verification package for Laravel with polymorphic support and event-driven delivery

00PHPCI passing

Pushed todayCompare

[ Source](https://github.com/nakanakaii/otp-service)[ Packagist](https://packagist.org/packages/nakanakaii/otp-service)[ RSS](/packages/nakanakaii-otp-service/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersionsUsed By (0)

nakanakaii/otp-service
======================

[](#nakanakaiiotp-service)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cfcc928578105960cbd99222236afa56b75b9c12a237da0e8c5719af21b53c34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e616b616e616b6169692f6f74702d73657276696365)](https://packagist.org/packages/nakanakaii/otp-service)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

A reusable Laravel package for OTP verification with polymorphic model support and event-driven delivery. Any model (User, Order, Device, etc.) can use OTP via polymorphic relations. Consumers write their own listener to send OTP via their preferred channel (SMS, WhatsApp, email, etc.).

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9+

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

[](#installation)

```
composer require nakanakaii/otp-service
```

Publish the config and migration:

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

Run the migration:

```
php artisan migrate
```

Setup
-----

[](#setup)

### 1. Write a Listener

[](#1-write-a-listener)

The package fires an `OtpRequested` event when an OTP is generated. Create a listener to send it via your preferred channel:

```
