PHPackages                             aliarefavin/avinauthpackage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. aliarefavin/avinauthpackage

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

aliarefavin/avinauthpackage
===========================

Custom authentication system for Laravel

1.1.1(7mo ago)1883MITPHPPHP ^8.0|^8.1|^8.2|^8.3

Since Apr 7Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/aliarefavin/avinauthpackage)[ Packagist](https://packagist.org/packages/aliarefavin/avinauthpackage)[ Docs](https://github.com/aliarefavin/avinauthpackage)[ RSS](/packages/aliarefavin-avinauthpackage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (13)Used By (0)

AvinAuth OTP Verification (Redis / Database)
============================================

[](#avinauth-otp-verification-redis--database)

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

🔐 Secure &amp; 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
------------

[](#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)

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
-----

[](#usage)

### Send code to the user

[](#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

[](#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 &amp; Inspiration 🙌
---------------------------

[](#credits--inspiration-)

- This package is heavily inspired by the excellent work of the [Sanjab Verify package](https://github.com/sanjabteam/verify). Special thanks to the Sanjab team for their elegant design and contribution to the Laravel ecosystem.

Contributing 🛠️
---------------

[](#contributing-️)

Contributions are welcome!

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

License 📝
---------

[](#license-)

This project is open-sourced under the MIT license.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance64

Regular maintenance activity

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~16 days

Recently: every ~44 days

Total

12

Last Release

222d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/818af8021b00d974193f38b5b9b4492614c3ff9247b7a45ff1f655521f12199e?d=identicon)[aliarefavin](/maintainers/aliarefavin)

---

Top Contributors

[![aliarefavin](https://avatars.githubusercontent.com/u/178640639?v=4)](https://github.com/aliarefavin "aliarefavin (14 commits)")[![AliArefzadeh](https://avatars.githubusercontent.com/u/130400679?v=4)](https://github.com/AliArefzadeh "AliArefzadeh (1 commits)")

---

Tags

laravelvalidationauthAuthenticationverifyauthenticateverificationone-time-passwordlaravel toolsoptavinavinmediaavintechaliaref

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aliarefavin-avinauthpackage/health.svg)

```
[![Health](https://phpackages.com/badges/aliarefavin-avinauthpackage/health.svg)](https://phpackages.com/packages/aliarefavin-avinauthpackage)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M347](/packages/tymon-jwt-auth)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M52](/packages/php-open-source-saver-jwt-auth)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[wotz/laravel-verification-code

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

6146.8k](/packages/wotz-laravel-verification-code)[tg/tgwebvalid

An easy way to validate Telegram Login Widget and Telegram Mini App users on your website using PHP

6821.7k1](/packages/tg-tgwebvalid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
