Download the PHP package prasanth-j/otpify without Composer

On this page you can find all versions of the php package prasanth-j/otpify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package otpify

Otpify

Build Status Total Downloads Latest Version on Packagist License: MIT

A secure, flexible OTP (One-Time Password) package for Laravel. Supports database and cache storage drivers, multiple purposes per identifier, hashed token storage, events, and a ready-made validation rule.

Requirements

Each Laravel major has its own PHP range and support window (per Laravel's official support policy), so the actual floor depends on which Laravel version you're on:

Laravel PHP range Security fixes until
9 8.0 – 8.2 (this package requires 8.1+) Feb 2024 — EOL
10 8.1 – 8.3 Feb 2025 — EOL
11 8.2 – 8.4 Mar 2026 — EOL
12 8.2 – 8.5 Feb 2027
13 8.3 – 8.5 Mar 2028

Laravel 9, 10, and 11 no longer receive security fixes upstream. This package still works on them, but for new projects prefer Laravel 12 or 13.

Installation

Publish the config file:

If you plan to use the database driver (the default), publish and run the migration:

Configuration

config/otpify.php:

Key Description
driver database or cache.
digits Default OTP length (4-8). Can be overridden per call.
validity Default expiry time in minutes. Can be overridden per call.
type Default character set: numeric, alpha, or alphanumeric.
cache.prefix Prefix used to build cache keys (otpify:{identifier}:{purpose}).
cache.store Which cache store to use. null uses your app's default store.

Security

Usage

Generate an OTP

With a purpose and custom options:

Generating a new OTP for the same identifier + purpose deletes any previous one — only the latest OTP for a given identifier/purpose is ever valid.

Validate an OTP

OtpResult status values and helpers:

Status Helper Meaning
valid isValid() Token matched, unused, not expired.
invalid isInvalid() Token does not match.
expired isExpired() Token matched an OTP that has expired.
already_used isAlreadyUsed() OTP was already validated once.
not_found — No OTP exists for that identifier/purpose.
generated wasGenerated() Returned only by generate()/resend().

Invalidate an OTP

Resend an OTP

Invalidates any existing OTP for the identifier/purpose and generates a fresh one:

Multiple purposes

Every method accepts a purpose so the same identifier can hold independent OTPs at once, e.g. 'login', '2fa', 'password-reset'.

Validation rule

Use OtpRule to validate an OTP as part of a normal Laravel form request or validator:

Events

Event Fired when
PrasanthJ\Otpify\Events\OtpGenerated An OTP is generated. Has identifier, purpose, token, expiresAt.
PrasanthJ\Otpify\Events\OtpValidated An OTP passes validation. Has identifier, purpose.
PrasanthJ\Otpify\Events\OtpFailed An OTP fails validation. Has identifier, purpose, reason (the failure status).

Drivers

Database (default)

Stores hashed OTPs in the otpify_tokens table. Requires the migration to be run. Good default choice — durable, works with the otpify:clean command.

Cache

Stores hashed OTPs in your configured cache store under otpify:{identifier}:{purpose}, using the OTP's expiry as the cache TTL. No migration needed; good fit if you already run Redis/Memcached and don't need a durable audit trail.

Rate limiting

Otpify does not rate limit generation/validation attempts itself — pair it with Laravel's RateLimiter:

Do the same around Otpify::validate() to slow down brute-force guessing attempts.

Cleaning up expired tokens

For the database driver, expired and used rows accumulate over time. Clean them up with:

Schedule it in routes/console.php (Laravel 11+) or app/Console/Kernel.php (Laravel 9/10):

This command is a no-op (with a warning) when the cache driver is active, since cache entries expire on their own via TTL.

Migrating from v1

v2.0.0 is a full rewrite and breaking change:

If you have existing data in the old otps table, write a one-off migration to hash and copy identifier/otp_type/token/expiry data into otpify_tokens, or simply let outstanding OTPs expire naturally and drop the old table.

Development

Larastan 3.x requires PHP 8.2+ locally to run static analysis, even though the package itself supports PHP 8.1+.

License

MIT


All versions of otpify with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/cache Version ^9.0|^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package prasanth-j/otpify contains the following files

Loading the files please wait ...