A professional, production-ready OTP (One-Time Password) package for Laravel applications.
composer require rawnoq/laravel-otpPublish the configuration file:
php artisan vendor:publish --tag=otp-configuse Rawnoq\LaravelOtp\Facades\Otp;
$otp = Otp::generate('user@example.com', 'email');
$code = $otp->otp_code;$otp = Otp::verify('user@example.com', '123456', 'email');
if ($otp) {
// OTP is valid and has been marked as used
}if (Otp::isValid('user@example.com', '123456', 'email')) {
// OTP is valid
}$otp = Otp::getLatest('user@example.com', 'email');$count = Otp::countActive('user@example.com', 'email');$deleted = Otp::cleanup();Otp::deleteActive('user@example.com', 'email');Edit config/otp.php to customize:
- Default OTP length
- Default expiry time
- Dev mode settings
- Type-specific configurations (phone, email, etc.)
MIT