adevesa/laravel-simple-otp

Generate and validate OTPs for your applications
1,682
Install
composer require adevesa/laravel-simple-otp
Latest Version:1.0.2
PHP:^8.1
Laravel:10
License:MIT
Last Updated:Apr 20, 2026
Links: GitHub  ·  Packagist
Maintainer: adevesa

Laravel Simple OTP

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package is a simple OTP generator for Laravel. You can use it to generate OTPs and validate them.

Installation

You can install the package via composer:

composer require adevesa/laravel-simple-otp

You can publish and run the migrations and publish the config file with:

php artisan vendor:publish --provider="adevesa\SimpleOTP\SimpleOTPServiceProvider"
php artisan migrate

This is the contents of the published config file:

return [
    'otp_length' => env('SIMPLE_OTP_LENGTH', 6),
    'otp_format' => env('SIMPLE_OTP_FORMAT', 'alpha_numeric'),
    'otp_expiration_minutes' => env('SIMPLE_OTP_EXPIRATION_MINUTES', 5),
    'otp_max_attempts' => env('SIMPLE_OTP_MAX_ATTEMPTS', 3),
    'otp_throw_exceptions' => env('SIMPLE_OTP_THROW_EXCEPTIONS', true),
];

With the otp_throw_exceptions option you can control if the package should throw exceptions or return false when an OTP is not valid.

Usage

$simpleOTP = new adevesa\SimpleOTP();
$code = $simpleOTP->create('a_email@example.com');
$simpleOTP->verify('a_email@example.com', "ASD123");

Or also

$code = \adevesa\SimpleOTP\Facades\SimpleOTP::create('+5491123456789')->code;
$isValid = \adevesa\SimpleOTP\Facades\SimpleOTP::verify('+5491123456789', $code);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

If you discover any security-related issues, please email adevesa95@outlook.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

pushery/email-magic-link-for-laravel

Passwordless email magic-link & OTP authentication for Laravel — standalone or w...

11,787 46
lakm/nopass

Provides passwordless authentication for your laravel projects.

20,817 22
aqlx86/sms-otp

SMS OTP for Laravel 5 using iSMS gateway.

692 3
lakshmaji/uniquecode

OTP generating package

1,121 4
lakshmajim/uniquecode

OTP generating package

224 4

Version History

Version Released PHP Laravel License
1.0.2 ^8.1 ^10.0 MIT
1.0.1 ^8.1 ^10.0 MIT
1.0.0 ^8.1 ^10.0 MIT