PHPackages                             alexgeno/phone-verification-laravel - 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. [Database &amp; ORM](/categories/database)
4. /
5. alexgeno/phone-verification-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

alexgeno/phone-verification-laravel
===================================

A library for phone verification via Laravel notification channels. Any notification channel can be used as a sender, and Redis or MongoDB can be used as a storage.

v1.0.3(2y ago)112.4kMITPHPPHP ^8.0

Since Aug 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/alexeygeno/phone-verification-laravel)[ Packagist](https://packagist.org/packages/alexgeno/phone-verification-laravel)[ Docs](https://github.com/alexeygeno/phone-verification-laravel)[ RSS](/packages/alexgeno-phone-verification-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (12)Versions (5)Used By (0)

Phone Verification via [Laravel Notification Channels](https://laravel-notification-channels.com/)
==================================================================================================

[](#phone-verification-via-laravel-notification-channels)

[![Build Status](https://github.com/alexeygeno/phone-verification-laravel/workflows/Tests/badge.svg)](https://github.com/alexeygeno/phone-verification-laravel/actions/workflows/tests.yml)[![Build Status](https://github.com/alexeygeno/phone-verification-laravel/workflows/Pint/badge.svg)](https://github.com/alexeygeno/phone-verification-laravel/actions/workflows/pint.yml)[![Build Status](https://github.com/alexeygeno/phone-verification-laravel/workflows/PHPStan/badge.svg)](https://github.com/alexeygeno/phone-verification-laravel/actions/workflows/php-stan.yml)[![Coverage Status](https://camo.githubusercontent.com/1b178244fd458980289dd100b578a7a79e413f939294459d12300795442e91b3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f616c6578657967656e6f2f70686f6e652d766572696669636174696f6e2d6c61726176656c2f62616467652e737667)](https://coveralls.io/github/alexeygeno/phone-verification-laravel)

Signing in or signing up on a modern website or mobile app typically follows these steps:

- A user initiates verification by submitting a phone number
- The user receives an SMS or a call with a one-time password [(OTP)](https://en.wikipedia.org/wiki/One-time_password)
- The user completes verification by submitting the [OTP](https://en.wikipedia.org/wiki/One-time_password)

This library is built on top of [ alexeygeno/phone-verification-php ](https://github.com/alexeygeno/phone-verification-php) and allows to set this up

Supported features
------------------

[](#supported-features)

- [Easy](#different-storages-and-notification-channels) switching between different storages and notification channels
- Configurable length and expiration time for [OTP](https://en.wikipedia.org/wiki/One-time_password)
- Configurable rate limits
- Localization
- Usage with different Laravel approaches: [automatic injection](https://laravel.com/docs/9.x/container#automatic-injection), [facade](https://laravel.com/docs/9.x/facades), and [commands](https://laravel.com/docs/9.x/artisan#writing-commands)
- Logging notifications instead of sending real ones, beneficial for non-production environments
- Out-of-the-box routes for quick start

Requirements
------------

[](#requirements)

- [Laravel 9.x](https://laravel.com/docs/9.x)
- Any of the available [Laravel Notification Channels](https://laravel-notification-channels.com/): [laravel/vonage-notification-channel](https://github.com/laravel/vonage-notification-channel), [laravel-notification-channels/twilio](https://github.com/laravel-notification-channels/twilio), [laravel-notification-channels/messagebird](https://github.com/laravel-notification-channels/messagebird) and [many more ](https://github.com/laravel-notification-channels?q=&type=all&language=php&sort=)
- Any of the supported storages: [predis/predis](https://github.com/predis/predis), [jenssegers/laravel-mongodb](https://github.com/jenssegers/laravel-mongodb)

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

[](#installation)

```
composer require alexgeno/phone-verification-laravel predis/predis laravel/vonage-notification-channel
```

**Note:** Redis as a storage and Vonage as a notification channel are defaults in the configuration

Usage
-----

[](#usage)

#### Automatic injection

[](#automatic-injection)

```
public function initiate(\AlexGeno\PhoneVerification\Manager\Initiator $manager)
{
    $manager->initiate('+15417543010');
}
```

```
public function complete(\AlexGeno\PhoneVerification\Manager\Completer $manager)
{
    $manager->complete('+15417543010', 1234);
}
```

#### Facade

[](#facade)

```
\AlexGeno\PhoneVerificationLaravel\Facades\PhoneVerification::initiate('+15417543010');
```

```
\AlexGeno\PhoneVerificationLaravel\Facades\PhoneVerification::complete('+15417543010', 1234);
```

#### Commands

[](#commands)

```
php artisan phone-verification:initiate --to=+15417543010
```

```
php artisan phone-verification:complete --to=+15417543010 --otp=1234
```

#### Routes

[](#routes)

```
curl -d "to=+15417543010" localhost/phone-verification/initiate
{"ok":true,"message":"Sms has been sent. Check your Phone!"}
```

```
curl -d "to=+15417543010&otp=1234" localhost/phone-verification/complete
{"ok":true,"message":"The verification is done!"}
```

**Note**: The package routes are available by default. To make them unavailable without redefining the service provider, change the bool key **phone-verification.sender.to\_log** in the configuration

Configuration
-------------

[](#configuration)

```
[
    'storage' => [
        'driver' => 'redis', // 'redis' || 'mongodb'
        'redis' => [
            'connection' => 'default',
            // the key settings - normally you don't need to change them
            'settings' => [
                'prefix' => 'pv:1',
                'session_key' => 'session',
                'session_counter_key' => 'session_counter',
            ],
        ],
        'mongodb' => [
            'connection' => 'mongodb',
            // the collection settings - normally you don't need to change them
            'settings' => [
                'collection_session' => 'session',
                'collection_session_counter' => 'session_counter',
            ],
        ],
    ],
    'sender' => [
        'driver' => 'vonage', // 'vonage' || 'twilio' || 'messagebird' and many more https://github.com/laravel-notification-channels
        'channel' => \Illuminate\Notifications\Channels\VonageSmsChannel::class, // \Illuminate\Notifications\Channels\VonageSmsChannel::class || \NotificationChannels\Twilio\TwilioChannel::class || \NotificationChannels\Messagebird\MessagebirdChannel::class and many more https://github.com/laravel-notification-channels
        'to_log' => false, // if enabled: instead of sending a real notification, debug it to the app log
    ],
    'routes' => true, // managing the availability of the package routes without redefining the service provider
    'manager' => [
        'otp' => [
            'length' => env('PHONE_VERIFICATION_OTP_LENGTH', 4), // 1000..9999
        ],
        'rate_limits' => [
            'initiate' => [ // for every 'to' no more than 10 initiations over 24 hours
                'period_secs' => env('PHONE_VERIFICATION_RATE_LIMIT_INITIATE_PERIOD_SECS', 86400),
                'count' => env('PHONE_VERIFICATION_RATE_LIMIT_INITIATE_COUNT', 10),
            ],
            'complete' => [ // for every 'to' no more than 5 failed completions over 5 minutes
                'period_secs' => env('PHONE_VERIFICATION_RATE_LIMIT_COMPLETE_PERIOD_SECS', 300), // this is also the expiration period for OTP
                'count' => env('PHONE_VERIFICATION_RATE_LIMIT_COMPLETE_COUNT', 5),
            ],
        ],
    ],
];
```

Different storages and notification channels
--------------------------------------------

[](#different-storages-and-notification-channels)

To switch between [available](#requirements) storages and notifications channels, install the respective package and update the configuration. For example, to use **Mongodb** as a storage and **Twilio** as a notification channel:

```
composer require jenssegers/mongodb laravel-notification-channels/twilio
```

```
[
    'storage' => [
        'driver' => 'mongodb',
        // ...
    ],
    'sender' => [
        'driver' => 'twilio',
        'channel' => \NotificationChannels\Twilio\TwilioChannel::class,
        // ...
    ],
    // ...
]
```

If the available options are not sufficient, you can redefine the service provider and add a custom storage (implementing **\\AlexGeno\\PhoneVerification\\Storage\\I**) or/and a sender (implementing **\\AlexGeno\\PhoneVerification\\Sender\\I**)

Publishing
----------

[](#publishing)

#### Config

[](#config)

```
php artisan vendor:publish --tag=phone-verification-config
```

#### Localization

[](#localization)

```
php artisan vendor:publish --tag=phone-verification-lang
```

#### Migrations

[](#migrations)

```
php artisan vendor:publish --tag=phone-verification-migrations
```

**Note**: Only the **MongoDB** storage driver requires migrations

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~0 days

Total

4

Last Release

1008d ago

### Community

Maintainers

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

---

Top Contributors

[![alexeygeno](https://avatars.githubusercontent.com/u/742557?v=4)](https://github.com/alexeygeno "alexeygeno (59 commits)")

---

Tags

2fa2factorauthenticationclickatellmessagebirdmongomongodbnotificationnotification-channelphoneredissigninsignupsmstouch-smstwilioverificationverifyverify-by-phonevonageotpAuthenticationnotificationverify2faredisphonesmstwiliomongodbsigninmongovonageverificationsignupturbosmsauthy2factorsmsapiAfricastalkingverify-by-phoneall-my-smsnotification-channelclickatellsms77messagebird46elkssipgatejusibecmsmsSmsPohvodafonetouch-smssmsc-rusms-broadcast

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alexgeno-phone-verification-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/alexgeno-phone-verification-laravel/health.svg)](https://phpackages.com/packages/alexgeno-phone-verification-laravel)
```

###  Alternatives

[mmucklo/queue-bundle

Symfony2/3/4/5 Queue Bundle (for background jobs) supporting Mongo (Doctrine ODM), Mysql (and any Doctrine ORM), RabbitMQ, Beanstalkd, Redis, and ... {write your own}

120839.8k](/packages/mmucklo-queue-bundle)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[rinvex/authy

Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

35188.4k1](/packages/rinvex-authy)[rinvex/laravel-authy

Rinvex Authy is a simple wrapper for Authy TOTP, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

3376.7k1](/packages/rinvex-laravel-authy)[jenssegers/mongodb-sentry

An extension for Laravel-MongoDB that lets you work with Sentry

5445.0k1](/packages/jenssegers-mongodb-sentry)[gr8shivam/laravel-sms-api

A modern, flexible Laravel package for integrating any SMS gateway with REST API support

10138.4k](/packages/gr8shivam-laravel-sms-api)

PHPackages © 2026

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