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

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

shawsank/otp
============

Laravel5 OTP manager

1.0.0(6y ago)129MITPHPPHP &gt;=5.4

Since Jan 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/shawsank/laravel-otp)[ Packagist](https://packagist.org/packages/shawsank/otp)[ RSS](/packages/shawsank-otp/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (2)Used By (0)

laravel-otp
===========

[](#laravel-otp)

Laravel 5 OTP Generation.

The module generates OTPs and validates them. You can plug your own notifier (such as AWS SNS) to send the OTPs to various channels.

Several configuration options are provided:

- Expiration duration
- Maximum OTPs allowed for a client
- Length of OTP
- Blacklisting clients

---

Installation
============

[](#installation)

### Via composer

[](#via-composer)

1. Run `composer require shawsank/otp`
2. Add `Shawsank\OTP\OTPServiceProvider` to your providers array in `config/app.php`
3. Run `composer dump-autoload`
4. Run `php artisan vendor:publish`
5. Run `php artisan migrate`

Done!

---

Configuration options
=====================

[](#configuration-options)

The package publishes `config/otp.php`. It is well documented.

---

Usage
=====

[](#usage)

The package provides with the following helpers:

1. `Manager`
2. `Generator`
3. `Validator`

You can use `Manager` to interact with the whole module. It acts as a wrapper for the complete functionality. However, you are free to use other helpers to generate and validate the OTPs.

### Generate an OTP

[](#generate-an-otp)

To generate an OTP, call `generate` method of `Manager`. This takes two arguments: module and ID. Both are strings. You can pass anything here, but keep in mind that this combination will be used to validate the OTP. For e.g. `$manager->generate('users', '1')` will return an OTP for the combination of 'users' module and ID '1'.

### Validate an OTP

[](#validate-an-otp)

To validate, call `isValid()` of the manager. It will return boolean based on the validity of the OTP. Validation makes sure the module + ID is not blocked, and the token is not expired.

### Blocking and Unblocking

[](#blocking-and-unblocking)

Whenever the module + ID exceeds the maximum allowed (non-expired) OTPs, they will be blocked. You won't be able to generate anymore OTPs for that module + ID combination. Currently, there is no interface to unblock the clients. You need to manually remove the entry from the table `otp_blacklist`. Please check ToDo to check progress and thoughts on this feature.

### Notifications

[](#notifications)

The manager gives `notify()` method which accepts any implementation of `Notifier` interface. You can implement this interface as per your business logic.

You might want to call `useOtp()` of the manager after the varification process completes. If you do not call this method, OTP will remain valid till it reaches its expiry limit.

---

Contributions
=============

[](#contributions)

All contributions are welcome! Create a fork, create PRs, discuss!

---

TODO
====

[](#todo)

1. Add option for numeric/alphanumeric code generation
2. Provide a way to unblock clients
3. Provide example implementation(s) for Notifier
4. Find a better way to remove expired OTPs from DB

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

2312d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/98175853?v=4)[prspace](/maintainers/prspace)[@PRSpace](https://github.com/PRSpace)

---

Top Contributors

[![BagriyDmitriy](https://avatars.githubusercontent.com/u/13766285?v=4)](https://github.com/BagriyDmitriy "BagriyDmitriy (4 commits)")[![parvez-rahaman](https://avatars.githubusercontent.com/u/8875411?v=4)](https://github.com/parvez-rahaman "parvez-rahaman (4 commits)")[![dhavan-oviyum](https://avatars.githubusercontent.com/u/146936801?v=4)](https://github.com/dhavan-oviyum "dhavan-oviyum (2 commits)")[![codingquark](https://avatars.githubusercontent.com/u/456712?v=4)](https://github.com/codingquark "codingquark (1 commits)")[![donmbelembe](https://avatars.githubusercontent.com/u/10473277?v=4)](https://github.com/donmbelembe "donmbelembe (1 commits)")[![gildo](https://avatars.githubusercontent.com/u/133645?v=4)](https://github.com/gildo "gildo (1 commits)")

---

Tags

laravelotpotp generate

### Embed Badge

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

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

###  Alternatives

[lakm/nopass

Provides passwordless authentication for your laravel projects.

2213.6k2](/packages/lakm-nopass)

PHPackages © 2026

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