PHP code example of amedev / otp-login

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

    

amedev / otp-login example snippets


return [

    /*
    |--------------------------------------------------------------------------
    | Login Handler Configuration
    |--------------------------------------------------------------------------
    | Determines which login handler is active.
    | Supported options:
    |  - 'jwt'     : Uses JWT for authentication.
    |  - 'sanctum' : Uses Laravel Sanctum.
    |  - 'session' : Uses standard session-based login.
    | Override default with env variable `OTP_LOGIN_HANDLER`.
    */
    'handler' => [
        'key' => env('OTP_LOGIN_HANDLER', 'jwt'),
        'map' => [
            'jwt' => \OtpLogin\Handlers\JwtLoginHandler::class,
            'sanctum' => \OtpLogin\Handlers\SanctumLoginHandler::class,
            'session' => \OtpLogin\Handlers\SessionLoginHandler::class,
        ]
    ],

    /*
    |--------------------------------------------------------------------------
    | SMS Driver Configuration
    |--------------------------------------------------------------------------
    | Defines which SMS gateway driver to use for sending OTP codes.
    | Switch drivers with `OTP_SMS_DRIVER` environment variable.
    */
    'driver' => env('OTP_SMS_DRIVER', 'modirpayamak'),

    'drivers' => [
        'modirpayamak' => [
            'class' => \OtpLogin\Services\ModirPayamakSmsSender::class,
            'key' => env('SMS_PATTERN_CODE'),      // ModirPayamak API pattern code
            'sender' => env('SMS_SENDER', '10004346'), // Default sender number
            'username' => env('SMS_USERNAME'),
            'password' => env('SMS_PASSWORD'),
        ],
        'kavenegar' => [
            'class' => \OtpLogin\Services\KavenegarSmsSender::class,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | OTP Code Lifetime
    |--------------------------------------------------------------------------
    | Duration in seconds for which the OTP code remains valid.
    | Default is 120 seconds (2 minutes).
    */
    'code_lifetime' => 120,

    /*
    |--------------------------------------------------------------------------
    | Model Bindings
    |--------------------------------------------------------------------------
    | Allows overriding the default OTP model.
    | Useful if you want to extend or customize the OTP code model.
    */
    'models' => [
        'otp' => \OtpLogin\Models\OtpCode::class,
    ],

];
bash
php artisan vendor:publish --tag=otp-login-config
php artisan vendor:publish --tag=otp-login-migrations
php artisan vendor:publish --tag=otp-login-models
php artisan vendor:publish --tag=otp-login-translations
bash
php artisan migrate