New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

aliarefavin/avinauthpackage

Custom authentication system for Laravel
1,016 1

Larablocks Analysis

aliarefavin/avinauthpackage works with Laravel 10, 11 and 12 (latest release 1.1.1, Sep 30, 2025).

Laravel 8 and 9 in earlier releases.

Recommendation checks

Use with care

Use with care: meets 0 of 4 checks.

  • Latest release doesn't support Laravel 13, the current version
  • No release in the last 12 months (last: Sep 30, 2025)
  • 2 downloads a month (needs 10,000)
  • 1 GitHub star (needs 100)

State

Quiet
  • Last stable release: Sep 30, 2025.
  • No releases in the last 12 months.
  • First released: Apr 7, 2025.
  • Monthly downloads: 2.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require aliarefavin/avinauthpackage
Latest Version:1.1.1
PHP:^8.0|^8.1|^8.2|^8.3
Laravel:10 · 11 · 12
Older releases:8 · 9
License:MIT
Last Updated:Sep 30, 2025
Links: GitHub  ·  Packagist
Maintainer: aliarefavin

AvinAuth OTP Verification (Redis / Database)

A lightweight and customizable Laravel package for verifying mobile/email using one-time passwords (OTP) on Redis.

🔐 Secure & Simple    •    📦 Easily Integrates with Laravel    •    ✉️ SMS/Email Ready

Verify your user mobile/email with a one-time password using both Redis and Mysql Database.

Installation

You can install the package via composer:

composer require aliarefavin/avinauthpackage
php artisan migrate

Publish config file using:

php artisan vendor:publish --tag=avinauth-config

Configuration

Configuration is located at config/avinauthconfig.php. Here's what you can adjust:

connection: you can set your connection to redis or database as you wish

Note: The default connection is redis and we recommend to keep it that way specially for large scale projects. If you are not using redis on your project and want to use database connection make sure to run php artisan migrate after installing the package.

code: OTP code generation rules.

resend_delay : Time delay (in seconds) before allowing another resend.

max_attemps: Maximum verification attempts allowed.

max_resends: Total resends allowed in one hour.

Usage

Send code to the user

use AliArefAvin\AvinAuthPackage\Services\AvinAuthService;


$result = (new AvinAuthService())->sendOTP($mobile, $request, $class);
        // Check if the request was successful
        if ($result['success'] && !array_key_exists('seconds', $result)) {
            // If the request was successful and the 'seconds' key is not present in the result,
            // set the 'seconds' key to the configured resend delay time
            $result['seconds'] = config('avinauthconfig.resend_delay');
        }
        // Return the result array, which contains information about the request status
        return $result;

$class is your class that implements AliArefAvin\AvinAuthPackage\Contracts\AvinAuthInterface

this $class contains your custom function named send that you use to send the code for users (email|sms) for exmaple your $class will be new AuthenticateService()

namespace App\Services\Auth;

use AliArefAvin\AvinAuthPackage\Contracts\AvinAuthInterface;

class AuthenticateService implements AvinAuthInterface
{
    public function send(string $receiver, string $code)
    {
        try {
            $Message = 'کد ورود شما:' . PHP_EOL .
                "code: $code" . PHP_EOL ;
                // If the receiver is not in the list of test numbers, send the SMS notification
                Notification::route(NotifyType::TSMS, []) // Set the notification route for SMS
                ->notify(
                    new SendSmsNotification( // Create a new SMS notification
                        $receiver, // The receiver's mobile number
                        $Message // The message content
                    )
                );
            return true; // Return true if the message was sent successfully
        } catch (Exception $e) {
            // If there is an exception (e.g., sending fails), return false
            return false; // Indicate that sending the code failed
        }
    }
}

Verify

You can verify code with request validation.

$request->validate([
    'mobile' => ['required'],
    'code' => 'required|avin_verify:mobile',
]);

mobile is your receiver which in this case is mobile.

Note: You can verify a code just once. so if you need to check code in two different requests then you should use something like the session to handle that.

Credits & Inspiration 🙌

  • This package is heavily inspired by the excellent work of the Sanjab Verify package. Special thanks to the Sanjab team for their elegant design and contribution to the Laravel ecosystem.

Contributing 🛠️

Contributions are welcome!

  • Fork the Project
  • Create a new branch
  • Add your changes
  • Submit a pull request 🙌

License 📝

This project is open-sourced under the MIT license.

Alternatives to aliarefavin/avinauthpackage

wotz/laravel-verification-code

A simple way to authenticate a user using a verification code.

95,500 58
jeremykenedy/laravel2step

Laravel 2 Step Authentication Package

116,080 279

Version History

Version Released PHP Laravel License
1.1.1 ^8.0|^8.1|^8.2|^8.3 ~10.0|~11.0|~12.0 MIT
1.1.0 ^8.0|^8.1|^8.2|^8.3 ~10.0|~11.0|~12.0 MIT
1.0.9 ^8.0|^8.1|^8.2|^8.3 ~10.0|~11.0|~12.0 MIT
1.0.8 ^8.0|^8.1|^8.2|^8.3 ~10.0|~11.0|~12.0 MIT
1.0.7 ^8.0|^8.1|^8.2|^8.3 ~10.0|~11.0|~12.0 MIT