PHPackages                             waqar/otploginauthentication - 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. waqar/otploginauthentication

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

waqar/otploginauthentication
============================

A simple modified otp authentication

1.0(3y ago)03MITPHP

Since May 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/WaqarHussainKhalid/web-otp-authentication)[ Packagist](https://packagist.org/packages/waqar/otploginauthentication)[ RSS](/packages/waqar-otploginauthentication/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Login Otp Authentication
--------------------------------

[](#laravel-login-otp-authentication)

Two-factor authentication (2FA) adds an extra layer of security to your application by requiring users to provide a second factor of authentication, usually a code generated by an authentication app or sent via SMS. OTP stands for "one-time password", which means that the code is only valid for a short period of time and cannot be reused.

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

[](#installation)

Here is the complete video of the usage and installation of the package.

[ ![Otp Authentication](video/thumbnail.png)](https://www.youtube.com/watch?v=gjDkagdKp4U)#### Step 1: Install Laravel

[](#step-1-install-laravel)

This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:

```
composer create-project laravel/laravel example-app

```

#### Step 2: Setup Database Configuration

[](#step-2-setup-database-configuration)

After successfully installing the laravel app then after configuring the database setup. We will open the ".env" file and change the database name, username and password in the env file.

```
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Enter_Your_Database_Name
DB_USERNAME=Enter_Your_Database_Username
DB_PASSWORD=Enter_Your_Database_Password

```

#### Step 3: Install Auth Scaffold

[](#step-3-install-auth-scaffold)

Laravel's laravel/ui package provides a quick way to scaffold all of the routes and views you need for authentication using a few simple commands:

```
composer require laravel/ui

```

Next, we need to generate auth scaffold with bootstrap, so let's run the below command:

```
php artisan ui bootstrap --auth

```

Then, install npm packages using the below command

```
npm install

```

At last, built bootstrap CSS using the below command:

```
npm run dev

```

### Package Installation

[](#package-installation)

```
composer require waqar/otploginauthentication

```

#### Run Command

[](#run-command)

Now, run migration with following command:

```
php artisan auth:otp

```

Now, run migration with following command:

```
php artisan migrate

```

#### Step 4: Update Register Controller.

[](#step-4--update-register-controller)

##### Update the below functions in the register controller.

[](#update-the-below-functions-in-the-register-controller)

```
 /**
     * Get a validator for an incoming registration request.
     *
     * @param  array $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'mobile_no' => ['required', 'regex:/^\+(?:[0-9] ?){6,14}[0-9]$/', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array $data
     * @return \App\Models\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'mobile_no' => str_replace(' ', '', $data['mobile_no']),
            'password' => Hash::make($data['password']),
        ]);
    }

```

#### Step 5: Configure sender mail address in laravel .env file

[](#step-5-configure-sender-mail-address-in-laravel-env-file)

##### .env file:

[](#env-file)

```
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=TLS

```

#### Step 6: Create Twilio Account

[](#step-6-create-twilio-account)

First you need to create and add phone number. then you can easily get account SID, Token and Number.

Create Account from here: [www.twilio.com](http://www.twilio.com).

Next add Twilio Phone Number

Next you can get account SID, Token and Number and add these in the .env file like bellow:

#### .env

[](#env)

```
TWILIO_ACCOUNT_SID=XXXXXXXXXXXXXXXXX
TWILIO_AUTH_TOKEN=XXXXXXXXXXXXX
TWILIO_NUMBER=+XXXXXXXXXXX

```

All the required steps have been done, now you have to type the given below command and hit enter to run the Laravel app:

```
php artisan serve

```

Now, Go to your web browser, type the given URL and view the app output:

```
http://localhost:8000/login

```

##### I hope it can help you...

[](#i-hope-it-can-help-you)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

1096d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/04b5f5b3815b9dd159be6a09489fd518d1b500eb8c4c250795105b2965da4222?d=identicon)[WaqarHussainKhalid](/maintainers/WaqarHussainKhalid)

---

Top Contributors

[![WaqarHussainKhalid](https://avatars.githubusercontent.com/u/52109661?v=4)](https://github.com/WaqarHussainKhalid "WaqarHussainKhalid (1 commits)")

### Embed Badge

![Health badge](/badges/waqar-otploginauthentication/health.svg)

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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