Looking to hire Laravel developers? Try LaraJobs

laravel-otp maintained by rawnoq

Description
A professional OTP (One-Time Password) package for Laravel
Last update
2025/11/27 04:25 (dev-main)
License
Links
Downloads
47

Comments
comments powered by Disqus

Laravel OTP Package

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