rawnoq/laravel-otp

A professional OTP (One-Time Password) package for Laravel

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/rawnoq/laravel-otp

1.5.0 2025-11-27 03:25 UTC

This package is not auto-updated.

Last update: 2025-11-27 06:45:39 UTC


README

A professional, production-ready OTP (One-Time Password) package for Laravel applications.

Installation

composer require rawnoq/laravel-otp

Configuration

Publish the configuration file:

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

Usage

Generate OTP

use Rawnoq\LaravelOtp\Facades\Otp;

$otp = Otp::generate('user@example.com', 'email');
$code = $otp->otp_code;

Verify OTP

$otp = Otp::verify('user@example.com', '123456', 'email');

if ($otp) {
    // OTP is valid and has been marked as used
}

Check if OTP is Valid

if (Otp::isValid('user@example.com', '123456', 'email')) {
    // OTP is valid
}

Get Latest OTP

$otp = Otp::getLatest('user@example.com', 'email');

Count Active OTPs

$count = Otp::countActive('user@example.com', 'email');

Cleanup Expired OTPs

$deleted = Otp::cleanup();

Delete Active OTPs

Otp::deleteActive('user@example.com', 'email');

Configuration Options

Edit config/otp.php to customize:

  • Default OTP length
  • Default expiry time
  • Dev mode settings
  • Type-specific configurations (phone, email, etc.)

License

MIT