abdukhaligov/laravel-otp
Composer 安装命令:
composer require abdukhaligov/laravel-otp
包简介
The OTP package for Laravel.
README 文档
README
Reference
Introduction
This is a simple package to generate and validate OTPs (One Time Passwords). This can be implemented mostly in Authentication.
Installation
Install via composer
composer require abdukhaligov/laravel-otp
Add service provider to the config/app.php file
<?php /* |-------------------------------------------------------------------------- | Autoloaded Service Providers |-------------------------------------------------------------------------- | | The service providers listed here will be automatically loaded on the | request to your application. Feel free to add your own services to | this array to grant expanded functionality to your applications. | */ 'providers' => [ ... Abdukhaligov\LaravelOtp\OtpServiceProvider::class, ]; ...
Add alias to the config/app.php file
<?php /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => [ ... 'otp' => Abdukhaligov\LaravelOtp\OtpFacade::class, ]; ...
Run Migrations
php artisan migrate
Usage
Generate OTP
<?php Otp::generate(string $identifier, int $digits = 6, int $validity = 10) Otp::validate(string $identifier, string $token)
Delete expired tokens
You can delete expired tokens by running the following artisan command:
php artisan otp:clean
You can also add this artisan command to app/Console/Kernel.php to automatically clean on scheduled
<?php protected function schedule(Schedule $schedule) { $schedule->command('otp:clean')->daily(); }
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-14