PHPackages                             signdeer/otpz - 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. signdeer/otpz

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

signdeer/otpz
=============

First Factor One-Time Passwords for Laravel (Passwordless OTP Login)

v1.0.16(9mo ago)0767MITPHPPHP ^8.2

Since Jun 25Pushed 9mo agoCompare

[ Source](https://github.com/Signdeer/otpz)[ Packagist](https://packagist.org/packages/signdeer/otpz)[ Docs](https://github.com/signdeer/otpz)[ GitHub Sponsors](https://github.com/benbjurstrom)[ RSS](/packages/signdeer-otpz/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (13)Versions (16)Used By (0)

This fork is maintained by [Signdeer](https://signdeer.com), a secure, modern platform for e-signatures, approvals, and digital document workflows built for African teams and global standards.

First Factor One-Time Passwords for Laravel
===========================================

[](#first-factor-one-time-passwords-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b15c850504b9e8e814d993cc1b541e4bcbf7291ffc02f196c00b6e7efd16df93/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62656e626a75727374726f6d2f6f74707a2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/benbjurstrom/otpz)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1b11d680fba10c68c4f9269b5fd6b892b87defdb3fa31e2e383dad4c05f1bca0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656e626a75727374726f6d2f6f74707a2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/benbjurstrom/otpz/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2c646a6917696fbff375502d96a24887d66a75e84ce99b1d7cded0f76428391b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656e626a75727374726f6d2f6f74707a2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/benbjurstrom/otpz/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)

This package provides secure first factor one-time passwords (OTPs) for Laravel applications. Users enter their email and receive a one-time code to sign in.

- ✅ Rate-limited
- ✅ Configurable expiration
- ✅ Invalidated after first use
- ✅ Locked to the user's session
- ✅ Invalidated after too many failed attempts
- ✅ Detailed error messages
- ✅ Customizable mail template
- ✅ Auditable logs

Starter Kits
------------

[](#starter-kits)

### Laravel + React Starter Kit

[](#laravel--react-starter-kit)

1. **New Applications**

    Create a new Laravel project using the OTPz + React starter kit with the following command:

    ```
    laravel new --using benbjurstrom/otpz-react-starter-kit otpz-react
    ```
2. **Existing Applications**:

    You can see a diff of all changes needed to integrate OTPz with the official Laravel + React Starter Kit here:

### Laravel + Vue Starter Kit

[](#laravel--vue-starter-kit)

1. **New Applications**

    Create a new Laravel project using the OTPz + Vue starter kit with the following command:

    ```
    laravel new --using signdeer/otpz-vue-starter-kit otpz-vue
    ```
2. **Existing Applications**:

    You can see a diff of all changes needed to integrate OTPz with the official Laravel + Vue Starter Kit here:

### Laravel + Livewire Starter Kit

[](#laravel--livewire-starter-kit)

1. **New Applications**

    Create a new Laravel project using the OTPz + Livewire starter kit with the following command:

    ```
    laravel new --using signdeer/otpz-livewire-starter-kit otpz-livewire
    ```
2. **Existing Applications**:

    You can see a diff of all changes needed to integrate OTPz with the official Laravel + Livewire Starter Kit here:

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

[](#installation)

### 1. Install the package via composer:

[](#1-install-the-package-via-composer)

```
composer require signdeer/otpz
```

### 2. Publish and run the migrations

[](#2-publish-and-run-the-migrations)

```
php artisan vendor:publish --tag="otpz-migrations"
php artisan migrate
```

### 3. Add the package's interface and trait to your Authenticatable model

[](#3-add-the-packages-interface-and-trait-to-your-authenticatable-model)

```
// app/Models/User.php
namespace App\Models;

//...
use BenBjurstrom\Otpz\Models\Concerns\HasOtps;
use BenBjurstrom\Otpz\Models\Concerns\Otpable;

class User extends Authenticatable implements Otpable
{
    use HasFactory, Notifiable, HasOtps;

    // ...
}
```

### 4. (Optional) Add the following routes

[](#4-optional-add-the-following-routes)

Not needed with Laravel 12 starter kits. Instead, see the [Usage](#usage) section for examples.

```
// routes/auth.php
use BenBjurstrom\Otpz\Http\Controllers\GetOtpController;
use BenBjurstrom\Otpz\Http\Controllers\PostOtpController;
//...
Route::get('otpz/{id}', GetOtpController::class)
    ->name('otpz.show')->middleware('guest');

Route::post('otpz/{id}', PostOtpController::class)
    ->name('otpz.post')->middleware('guest');
```

### 5. (Optional) Publish the views for custom styling

[](#5-optional-publish-the-views-for-custom-styling)

```
php artisan vendor:publish --tag="otpz-views"
```

This package publishes the following views:

```
resources/
└── views/
    └── vendor/
        └── otpz/
            ├── otp.blade.php               (for entering the OTP)
            ├── components/template.blade.php
            └── mail/
                ├── notification.blade.php  (standard template)
                └── otpz.blade.php          (custom template)
```

### 6. (Optional) Publish the config file

[](#6-optional-publish-the-config-file)

```
php artisan vendor:publish --tag="otpz-config"
```

This is the contents of the published config file:

```
