rawnoq/laravel-otp
最新稳定版本:1.5.0
Composer 安装命令:
composer require rawnoq/laravel-otp
包简介
A professional OTP (One-Time Password) package for Laravel
README 文档
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
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-27