PHPackages                             larakeeps/authguard-otp - 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. larakeeps/authguard-otp

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

larakeeps/authguard-otp
=======================

AuthGuard OTP is a package intended for random code generation, validation and confirmation (OTP).

v1.0.3(3mo ago)256MITPHP

Since Feb 4Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/douglasssantos/authguard-otp)[ Packagist](https://packagist.org/packages/larakeeps/authguard-otp)[ Docs](https://github.com/douglasssantos/authguard-otp)[ RSS](/packages/larakeeps-authguard-otp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

**AuthGuard OTP**

> AuthGuard OTP is a package intended for random code generation, validation and confirmation (OTP). Normally the OTP is used with a validator code or token that is sent by email or SMS to authenticate or authorize a certain action in the project.

### This repository is only compatible with laravel: `7.*` to `11.*`

[](#this-repository-is-only-compatible-with-laravel-7-to-11)

Installation
------------

[](#installation)

First Step, execute the command.

```
composer require larakeeps/authguard-otp
```

Second step, run the migration to create the tables: `auth_guard_otp_codes`

```
php artisan migrate
```

Third step, publish the authguard configuration, to publish the configurations run the command below:

```
php artisan vendor:publish --tag=authguard-otp-config
```

**Generating otp code**

```
use Larakeeps\AuthGuard\Facades\OTP;

/**
 *
 * The create method has 3 parameters, 1 mandatory and 2 optional.
 *
 * The $reference parameter is used with the assertive condition function in code validation.
 * The $email parameter is used in the same way as the $reference parameter
 *
 * @param string $phone : required
 * @param string $email : optional
 * @param string $reference : optional
 *
 * @method static OTP create(string $phone, string|null $email, string|null $reference)
 *
 * */

$createOTP = OTP::create('phone number', 'email', 'reference');

// To retrieve the method return, call the following methods below.

/**
 *
 * The then method returns 2 parameters, $data of type AuthGuard, and $response of type Collection.
 *
 * @method then(Closure $destination)
 *
 * */

$createOTP->then(function (AuthGuard|null $data, Collection $response){

       /*
        * the $data parameter returns the null or Authguard model containing the table columns.
        */

       /*
        * The $response parameter returns a collection containing the following data:
        * number_digits, code, message, status, user.access_token, user.ip_address
        */

        return $data->expires_at; // returns a value of type Carbon::class;

        if($response->status){
            return $response->message;
        }

});

// OR through the get() method that returns a Collection

return $createOTP->get();

// OR like this

return OTP::get();

// OR through the getResponse() method that returns a Collection

return $createOTP->getResponse();

// OR like this

return OTP::getResponse();

// OR can be called individually using methods

return OTP::getData()->expires_at; // returns a value of type Carbon::class;

if(OTP::getStatus()){
    return OTP::getMessage();
}

return OTP::getAccessToken();
return OTP::getIpAddress();
```

**Checking for the existence of generated code and viewing the generated data.**

```
use Larakeeps\AuthGuard\Facades\OTP;

/**
 *
 * Method to check if the generated code exists.
 * $phone parameter is used for better code verification assertiveness.
 *
 * @method static bool hasCode(string $code, string|null $phone)
 *
 * */

$hasCode = OTP::hasCode('154896');

if($hasCode){
    return "The code exist."
}

/**
 *
 * Method for finding and returning data.
 * $phone parameter is used for better code verification assertiveness.
 *
 * @method static OTP getByCode(string $code, string|null $phone)
 *
 * */

$authGuardFounded = OTP::getByCode('154896', '5521985642205');

if($authGuardFounded){
    return $authGuardFounded
}
```

**Confirm whether the code entered is valid and whether it was actually confirmed.**

```
use Larakeeps\AuthGuard\Facades\OTP;

/**
 *
 * The create method has 3 parameters, 2 mandatory and 1 optional.
 *
 * The $reference parameter is used with the assertive condition function in code validation.
 *
 * @param string $code : required
 * @param string $phone : required
 * @param string $reference : optional
 *
 * @method static OTP confirm(string $code, string $phone, string|null $reference)
 *
 * */

$validateCode = OTP::confirm('154896', '5521985642205');

// To retrieve the method return, call the following methods below.

/**
 *
 * The then method returns 2 parameters, $data of type AuthGuard, and $response of type Collection.
 *
 * @method then(Closure $destination)
 *
 * */

$validateCode->then(function (null $data, Collection $response){

       /*
        *
        * Within the confirm() method, the $data parameter will always return a null value.
        *
        * The $response parameter returns a collection containing the following data:
        * number_digits, code, message, status, user.access_token, user.ip_address
        */

        if($response->status && OTP::isConfirmed()){
            return $response->message;
        }

        return $response->message;

});

// OR through the getResponse() method that returns a Collection

return $createOTP->getResponse();

// OR like this

return OTP::getResponse();

// OR can be called individually using methods

if(OTP::getStatus()){
    return OTP::getMessage();
}

return OTP::getAccessToken();
return OTP::getIpAddress();
```

**Deleting an OTP code.**

```
use Larakeeps\AuthGuard\Facades\OTP;

/**
 *
 * @method OTP deleteCode(string $code)
 *
 * */

$deletedCode = OTP::deleteCode();

// To retrieve the method return, call the following methods below.

/**
 *
 * The then method returns 2 parameters, $data of type AuthGuard, and $response of type Collection.
 *
 * @method then(Closure $destination)
 *
 * */

$validateCode->then(function (null $data, Collection $response){

       /*
        *
        * Within the deleteCode() method, the $data parameter will always return a null value.
        *
        * The $response parameter returns a collection containing the following data:
        * number_digits, code, message, status, user.access_token, user.ip_address
        */

        if($response->status){
            return $response->message;
        }

});

// OR through the getResponse() method that returns a Collection

return $createOTP->getResponse();

// OR like this

return OTP::getResponse();

// OR can be called individually using methods

if(OTP::getStatus()){
    return OTP::getMessage();
}

return OTP::getAccessToken();
return OTP::getIpAddress();
```

#### Don't forget to follow me on github and star the project.

[](#dont-forget-to-follow-me-on-github-and-star-the-project)

> ### My contacts
>
> [](#my-contacts)
>
> > E-mail:
> >
> > Linkedin: [Acessa Perfil](https://www.linkedin.com/in/douglas-da-silva-santos/) [![](https://camo.githubusercontent.com/963c0acef69284b79f7e3026da343df62ad91afc0d5df4d2a283f6cd3fb69951/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f64657669636f6e732f64657669636f6e2f69636f6e732f6c696e6b6564696e2f6c696e6b6564696e2d6f726967696e616c2e737667)](https://camo.githubusercontent.com/963c0acef69284b79f7e3026da343df62ad91afc0d5df4d2a283f6cd3fb69951/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f64657669636f6e732f64657669636f6e2f69636f6e732f6c696e6b6564696e2f6c696e6b6564696e2d6f726967696e616c2e737667)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance80

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~361 days

Total

3

Last Release

103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4f235b981bac409a25fb2f3e110f857c20e97194ce8e1f04c4402d2855002f6?d=identicon)[douglasssantos](/maintainers/douglasssantos)

---

Top Contributors

[![douglasssantos](https://avatars.githubusercontent.com/u/44000220?v=4)](https://github.com/douglasssantos "douglasssantos (11 commits)")

---

Tags

laravelvalidationcodeotpsecuritysmsaclpermissionrolespermissionsrbaclarakeeps

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/larakeeps-authguard-otp/health.svg)

```
[![Health](https://phpackages.com/badges/larakeeps-authguard-otp/health.svg)](https://phpackages.com/packages/larakeeps-authguard-otp)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[wnikk/laravel-access-rules

Simple system of ACR (access control rules) for Laravel, with roles, groups, unlimited inheritance and possibility of multiplayer use.

103.6k1](/packages/wnikk-laravel-access-rules)

PHPackages © 2026

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