PHP code example of clarity-tech / laravel-otp-generator

1. Go to this page and download the library: Download clarity-tech/laravel-otp-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

clarity-tech / laravel-otp-generator example snippets



// config for ClarityTech/LaravelOtpGenerator
return [
    'debug' => false,
    'expiry' => env('OTP_EXPIRY', 15 * 60),
    'length' => env('OTP_LENGTH', 6),
];


use ClarityTech\LaravelOtpGenerator\Facades\AugmentedOTP;

$otp     =  AugmentedOTP::generateWithKey(9706353416);

$isValid =  AugmentedOTP::withKey(9706353416)->validate(123456);

$isValid =  AugmentedOTP::withKey(9706353416)->verify(123456);//does not trigger exception
 
use ClarityTech\LaravelOtpGenerator\Exceptions\OTPExpiredException;
use ClarityTech\LaravelOtpGenerator\Exceptions\OTPInvalidException;

$instance = AugmentedOTP::fromRequest(Request $request, string $mobileNo);

$otp = $instance->generate();

$otp = $instance->validate(123456);
bash
php artisan vendor:publish --tag="laravel-otp-generator-config"