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

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

chapdel/verification-code
=========================

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

1.0.1(1y ago)0179MITPHPPHP ^8.4

Since Feb 25Pushed 1y agoCompare

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

READMEChangelog (2)Dependencies (8)Versions (3)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

32

—

LowBetter than 69% of packages

Maintenance41

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.2% 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

2

Last Release

493d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20987014?v=4)[Chapdel KAMGA](/maintainers/chapdel)[@chapdel](https://github.com/chapdel)

---

Top Contributors

[![gdebrauwer](https://avatars.githubusercontent.com/u/22586858?v=4)](https://github.com/gdebrauwer "gdebrauwer (70 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)")[![chapdel](https://avatars.githubusercontent.com/u/20987014?v=4)](https://github.com/chapdel "chapdel (2 commits)")[![codebeauty](https://avatars.githubusercontent.com/u/596842?v=4)](https://github.com/codebeauty "codebeauty (1 commits)")

---

Tags

laravelAuthenticationverificationverification Codeone-time code

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M146](/packages/laravel-cashier)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[wotz/laravel-verification-code

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

5962.6k](/packages/wotz-laravel-verification-code)[fouladgar/laravel-otp

This package provides convenient methods for sending and validating OTP notifications to users for authentication.

21227.6k](/packages/fouladgar-laravel-otp)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)

PHPackages © 2026

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