PHP code example of aliwebto / otp

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

    

aliwebto / otp example snippets


use Aliwebto\Otp\Otp;

// generate and send code
Otp::generate("09xxxxxxxxx");


// check entered code
Otp::check("code","09xxxxxxxxx");


// regenerate and send new code
Otp::regenerate("09xxxxxxxxx");


// get regenerate code cooldown in seconds
$code = Otp::lastCode("09xxxxxxxxx");
$seconds = Otp::regenerateCooldown($code);


// check code and login/register

$createUserIfNotExist = true;
$newUserEmail = random_int(100000,9999999)."@aliwento.com";
$newUserName = "User";

$isLoggedIn = Otp::authenticate("CODE","09xxxxxxxxx",$createUserIfNotExist,$newUserEmail,$newUserName);


bash
php artisan vendor:publish --provider="Aliwebto\Otp\OtpServiceProvider"
bash
php artisan migrate