1. Go to this page and download the library: Download amreljako/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/ */
amreljako / laravel-otp example snippets
use Otp;
Otp::send([
'destination' => '[email protected]',
'purpose' => 'login',
'channel' => 'mail', // or your sms/whatsapp driver
// 'ttl' => 300, 'digits' => 6, 'max_attempts' => 5,
]);
$ok = Otp::verify('[email protected]', 'login', $request->code);
if ($ok) { /* grant access */ } else { /* error */ }
class MySmsChannel implements \Amreljako\Otp\Contracts\OtpChannel {
public function send(\Amreljako\Otp\DTO\OtpPayload $p): bool {
// call provider API using $p->destination and $p->message()
return true;
}
}