PHPackages                             wotz/laravel-verification-code - 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. wotz/laravel-verification-code

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

wotz/laravel-verification-code
==============================

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

3.1.0(1y ago)6146.8k—6%19[1 issues](https://github.com/wotzebra/laravel-verification-code/issues)[1 PRs](https://github.com/wotzebra/laravel-verification-code/pulls)MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Feb 14Pushed 1mo ago5 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (22)Used By (0)

Laravel Verification Code
=========================

[](#laravel-verification-code)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b62ddd533b57dfb7e5e49806adfa3152fc5b7ed55fc882e241dce3dfd50be285/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f747a2f6c61726176656c2d766572696669636174696f6e2d636f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wotz/laravel-verification-code)[![Total Downloads](https://camo.githubusercontent.com/a6a9c0906d8dec5a6368e120809e172c5292bb668814304667c8c49830f1b632/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f747a2f6c61726176656c2d766572696669636174696f6e2d636f64652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wotz/laravel-verification-code)

This package makes it possible to authenticate a user via a verification code.

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

[](#installation)

You can install this package using composer:

```
composer require wotz/laravel-verification-code
```

The package will automatically register itself.

You can publish the migration with:

```
php artisan vendor:publish --provider="Wotz\VerificationCode\VerificationCodeServiceProvider" --tag="migrations"
```

After publishing the migration, run the migration with:

```
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Wotz\VerificationCode\VerificationCodeServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### Generate and send a verification code

[](#generate-and-send-a-verification-code)

```
use Wotz\VerificationCode\VerificationCode;

VerificationCode::send($email);
```

This will generate a verification code for the user. The code will be stored in the `verification_codes` table. An email with the generated code will then be sent to the user matching the given email address.

### Verify a verification code

[](#verify-a-verification-code)

```
use Wotz\VerificationCode\VerificationCode;

VerificationCode::verify($code, $email);
```

If the verification code is expired or does not match the user's email address, it will return `false`. If valid, it will return `true` and delete the code.

If you do not want the code to be deleted (in case the same code needs to be verified at different points in the login flow) you can pass a third parameter.

```
use Wotz\VerificationCode\VerificationCode;

VerificationCode::verify($code, $email, $deleteAfterVerification);
```

### Verification codes table cleanup

[](#verification-codes-table-cleanup)

Since it is possible for the verification codes table to fill up with unused codes, the following command will prune all codes older than the given hours.

```
php artisan verification-code:prune --hours=24
```

Config settings
---------------

[](#config-settings)

### Length

[](#length)

This value defines the length of every generated verification code.

### Characters

[](#characters)

You can define which characters are used to generate a verification code. By default, certain characters are excluded (0, O, I, L) because they look too similar.

### Expire seconds

[](#expire-seconds)

A verification code is only valid for a certain amount of time. You can define after how many seconds a verification code will expire.

### Max codes per verifiable

[](#max-codes-per-verifiable)

By default, only one verification code can be active per verifiable. If you want to allow multiple active codes per verifiable, then you can change this setting to a different number (or to `null` if you want unlimited codes per verifiable).

### Custom Notification

[](#custom-notification)

If you want to use a custom notification to send the verification code, you can create your own notification class which should extend the `VerificationCodeCreatedInterface`. Make sure you don't forget to pass the verification code to the mail.

### Custom Model

[](#custom-model)

If you want to use a custom verification code model, you can create your own verification code class which should extend the `VerificationCode`.

### Queue

[](#queue)

If your notification is queueable, you can define the queue that will be used for the notification.

### Test verifiables and test code

[](#test-verifiables-and-test-code)

You sometimes may want to allow a user to log in immediately without letting them go through the verification code flow. To do this you can add the verifiable (e.g. email address) to the `test_verifiables` array. You then need to define a `test_code`. The combination of the verifiable and the test code will make it possible for the user to pass through.

Testing
-------

[](#testing)

You can run tests with:

```
composer test
```

Linting
-------

[](#linting)

```
composer lint
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Günther Debrauwer](https://github.com/gdebrauwer)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance70

Regular maintenance activity

Popularity46

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 66.1% 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 ~92 days

Recently: every ~111 days

Total

21

Last Release

440d ago

Major Versions

0.3.4 → 1.0.02020-12-16

v1.x-dev → 2.0.02023-08-25

2.1.1 → 3.0.02024-09-26

PHP version history (7 changes)0.1.0PHP ^7.3

1.1.0PHP ^7.3|^8.0

1.2.0PHP ^7.3|^7.4|^8.0|^8.1

1.3.0PHP ^7.3|^7.4|^8.0|^8.1|^8.2

2.0.0PHP ^8.1|^8.2

2.1.0PHP ^8.1|^8.2|^8.3

3.1.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/739571b3160077a91cf01209a045409a0daf361b73fae482f37dfcf1db301a57?d=identicon)[gdebrauwer](/maintainers/gdebrauwer)

![](https://www.gravatar.com/avatar/15cf50c665151125e406b8daceaca4ce27096798f9295cbae2f17b29440241f6?d=identicon)[Who Owns The Zebra](/maintainers/Who%20Owns%20The%20Zebra)

---

Top Contributors

[![gdebrauwer](https://avatars.githubusercontent.com/u/22586858?v=4)](https://github.com/gdebrauwer "gdebrauwer (76 commits)")[![Bart-Kuenen-nextapps](https://avatars.githubusercontent.com/u/107543678?v=4)](https://github.com/Bart-Kuenen-nextapps "Bart-Kuenen-nextapps (18 commits)")[![yinx](https://avatars.githubusercontent.com/u/1022847?v=4)](https://github.com/yinx "yinx (13 commits)")[![earnould](https://avatars.githubusercontent.com/u/5271576?v=4)](https://github.com/earnould "earnould (3 commits)")[![jan-claeys](https://avatars.githubusercontent.com/u/32668993?v=4)](https://github.com/jan-claeys "jan-claeys (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![codebeauty](https://avatars.githubusercontent.com/u/596842?v=4)](https://github.com/codebeauty "codebeauty (1 commits)")

---

Tags

authenticationlaravelphpverificationlaravelAuthenticationverificationverification Codeone-time code

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/wotz-laravel-verification-code/health.svg)

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

###  Alternatives

[laragear/two-factor

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

339785.3k8](/packages/laragear-two-factor)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6712.1k2](/packages/hasinhayder-tyro)[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)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2011.0k](/packages/alajusticia-laravel-logins)

PHPackages © 2026

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