PHP code example of tech-ed / simpl-otp
1. Go to this page and download the library: Download tech-ed/simpl-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/ */
tech-ed / simpl-otp example snippets
return [
'success_messages' => [
'otp_generated' => 'OTP generated',
'otp_valid' => 'OTP is valid',
],
'error_messages' => [
'invalid_type' => 'Invalid OTP type',
'expired_otp' => 'OTP Expired',
'invalid_otp' => 'Invalid OTP',
'otp_not_found' => 'OTP not found',
],
'otp' => [
'length' => 4,
'type' => 'numeric',
'validity' => 15,
]
];
use TechEd\SimplOtp\SimplOtp;
$identifier = '[email protected] ';
$otp = SimplOtp::generate($identifier);
$identifier = '[email protected] ';
$token = '1234'; // OTP token to validate
$result = SimplOtp::validate($identifier, $token);
return view('simplotp::generate');
return view('simplotp::verify');
@extends('layouts.app')
@section('content')
// The existing view content goes here
@endsection
$user = auth()->user();
$otp = SimplOtp::generate($user->email);
if($otp->status === true){
$user->notify(new EmailOtpVerification($otp->token));
}
return $otp;
bash
php artisan migrate
bash
php artisan vendor:publish --provider="TechEd\SimplOtp\SimplOtpServiceProvider" --tag="config"
bash
php artisan simplotp:publish-frontend
bash
php artisan vendor:publish --provider="TechEd\SimplOtp\SimplOtpServiceProvider" --tag="email"