PHP code example of bonabrian / laravel-otp

1. Go to this page and download the library: Download bonabrian/laravel-otp 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/ */

    

bonabrian / laravel-otp example snippets


use Bonabrian\Otp\Facades\Otp;

$code = Otp::generate($secret);

$valid = Otp::validate($code, $secret);

// Generate
Otp::setDigits(4)->generate($secret); // 4 Digits
Otp::setExpiry(30)->generate($secret); // 30 min expiry
Otp::setDigits(4)->setExpiry(30)->generate($secret); // 4 Digits, 30 min expiry
bash
php artisan otp:publish