ankurk91 / laravel-otp
One time password (OTP) generator and verifier.
1.3.1
2024-03-07 15:09 UTC
Requires
- php: ^8.2
- illuminate/cache: ^10 || ^11
- illuminate/support: ^10 || ^11
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0
- phpunit/phpunit: ^9.5 || ^10.0
README
One time password (OTP) generator and verifier.
Installation
You can install the package via composer:
composer require "ankurk91/laravel-otp"
Publish the config file (optional)
You can publish the config file into your project.
php artisan vendor:publish --provider="Ankurk91\LaravelOTP\OTPServiceProvider" --tag="config"
Usage
You can use the global helper function
<?php $phoneNumber = '+1234567890'; $secret = otp()->generate($phoneNumber, 6) // You can send $secret via SMS/Email to user otp()->match($phoneNumber, request('otp')); otp()->forget($phoneNumber);
or you can use Facade
<?php use Ankurk91\LaravelOTP\Facades\OTP; $secret = OTP::generate($phoneNumber)
Note The OTP will be stored in default cache storage.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
composer test
Security
If you discover any security issues, please email pro.ankurk1[at]gmail[dot]com
instead of using the issue tracker.
This packages does not follow the HOTP or TOTP specification.
License
The MIT License.