承接 tech-ed/simpl-otp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tech-ed/simpl-otp

最新稳定版本:v1.0.2

Composer 安装命令:

composer require tech-ed/simpl-otp

包简介

A simple and lightweight Laravel package for generating and verifying one-time passwords (OTPs), enhancing authentication security in your Laravel applications.

README 文档

README

A Laravel package for simple OTP generation and validation with built-in Blade frontend scaffolding.

Features

  • Generate and validate OTPs
  • Ready-to-use Blade views
  • Email notification support
  • Configurable settings
  • Easy integration

Quick Start

Installation

composer require tech-ed/simpl-otp
php artisan migrate

Basic Usage

use TechEd\SimplOtp\SimplOtp;

// Generate OTP
$otp = SimplOtp::generate('user@example.com');

// Validate OTP
$result = SimplOtp::validate('user@example.com', '1234');

Configuration

Publish the config file:

php artisan vendor:publish --provider="TechEd\SimplOtp\SimplOtpServiceProvider" --tag="config"

Configure OTP settings in config/simplotp.php:

return [
    'otp' => [
        'length' => 4,           // OTP length
        'type' => 'numeric',     // 'numeric' or 'alphanumeric'
        'validity' => 15,        // Validity in minutes
    ],
    'success_messages' => [
        'otp_generated' => 'OTP generated',
        'otp_valid' => 'OTP is valid',
    ],
    'error_messages' => [
        'expired_otp' => 'OTP Expired',
        'invalid_otp' => 'Invalid OTP',
        'otp_not_found' => 'OTP not found',
    ]
];

Frontend Views

Setup

php artisan simplotp:publish-frontend

Routes

  • Generate OTP: /simplotp/generate
  • Verify OTP: /simplotp/verify

Using in Your Controllers

return view('simplotp::generate');
return view('simplotp::verify');

Customization

The views are published to resources/views/vendor/simplotp/ and include Bootstrap styling. You can customize them to match your application's design.

Email Notifications

Publish Email Template

php artisan vendor:publish --provider="TechEd\SimplOtp\SimplOtpServiceProvider" --tag="email"

Send OTP via Email

use TechEd\SimplOtp\SimplOtp;
use TechEd\SimplOtp\EmailOtpVerification;

$user = auth()->user();
$otp = SimplOtp::generate($user->email);

if ($otp->status === true) {
    $user->notify(new EmailOtpVerification($otp->token));
}

Support

If SimplOtp has been helpful to you and you'd like to support its development, consider buying the developer a cup of coffee! ☕

Your support is greatly appreciated and helps in maintaining and improving SimplOtp for the Laravel community.

"Buy Me A Coffee"

统计信息

  • 总下载量: 570
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-19