PHP code example of kaffe-software / laravel-otp

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

    

kaffe-software / laravel-otp example snippets



   /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => [
        ...
        Ichtrojan\Otp\OtpServiceProvider::class,
    ];
...



   /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => [
        ...
        'Otp' => Ichtrojan\Otp\Otp::class,
    ];
...



Otp::generate(string $identifier, int $digits = 4, int $validity = 10)



$otp = Otp::generate('[email protected]', 6, 15);



Otp::validate(string $identifier, string $token)



$otp = Otp::validate('[email protected]', '282581');



protected function schedule(Schedule $schedule)
{
    $schedule->command('otp:clean')->daily();
}
bash
php artisan migrate
bash
php artisan otp:clean