PHPackages                             kohaku1907/lara2step - 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. kohaku1907/lara2step

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

kohaku1907/lara2step
====================

This is my package lara2step

v1.0.0(2y ago)06MITPHPPHP ^8.1

Since Nov 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kohaku1907/lara2step)[ Packagist](https://packagist.org/packages/kohaku1907/lara2step)[ Docs](https://github.com/kohaku1907/lara2step)[ RSS](/packages/kohaku1907-lara2step/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Lara2Step
=========

[](#lara2step)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f13cc1c80fcb2dd7b5172b910875d3b1556074da5518127ca403cc3be56b0d11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f68616b75313930372f6c61726132737465702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kohaku1907/lara2step)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f5d327257c5dac4e09bf0cf8a2d9f7d2e1a0469cbfebef1371f1281cf86d2506/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6f68616b75313930372f6c61726132737465702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/kohaku1907/lara2step/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/32447dbfa9f7e6fae4a55c98e6430c63a9257c64dc0c5044c3f9c8747a094fac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6f68616b75313930372f6c61726132737465702f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/kohaku1907/lara2step/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a31a50a9319ff031c39bb9d30665b3ee63e52ed5d544f2bdb9dcc0b0c9cbab3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6f68616b75313930372f6c61726132737465702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kohaku1907/lara2step)

Lara2Step is a Laravel package that provides two-step authentication to your Laravel applications.

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

[](#installation)

Install the package via composer:

```
composer require kohaku1907/lara2step
```

Publish and run the migrations with:

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

Publish the config file with:

```
php artisan vendor:publish --tag="2step-config"
```

This is the contents of the published config file:

```
return [
    'default_channel' => 'email', // email, sms
    'table_name' => 'two_step_auths', // table name
    'code_length' => 4, // code length
    'numeric_code' => false, // numeric code only
    'confirm_key' => '_2fa', // session key name
    'timeout' => 300, // timeout of verifed session in minutes
    'max_attempts' => 5, // max attempts
    'exceed_countdown_minutes' => 1440, // exceed countdown in minutes
    'resend_code_seconds' => 60, // resend code in seconds
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="2step-views"
```

Usage
-----

[](#usage)

The Lara2Step package can be integrated into your Laravel application by following these steps:

1. Implement the `TwoStepAuthenticatable` contract to your `User` model:
2. Add the `TwoStepAuthentication` trait to your `User` model:

Here is an example of a `User` model:

```
use Kohaku1907\Lara2step\Contracts\TwoStepAuthenticatable;
use Kohaku1907\Lara2step\TwoStepAuthentication;

class User extends Authenticatable implements TwoStepAuthenticatable {
    use TwoStepAuthentication;

    public function registerTwoStepAuthentication(): void
    {
        $this->configureForceEnable('email');
        $this->configureCodeFormat(length: 4, numericCode: true);
    }
}
```

In the `registerTwoStepAuthentication` method, you can configure the two-step authentication settings for the user. The following methods are available:

- `configureForceEnable(string $channel)`: Force enable two-step authentication for the user. The user will not be able to disable two-step authentication.
- `configureCodeFormat(int $length, bool $numericCode)`: Configure the code format for the user. The code length and whether the code should be numeric or not can be configured.

3. Add the alias middleware to routes that should be protected by two-step authentication:

```
Route::get('/dashboard', function () {
    // Only verified users...
})->middleware('2step');
```

The middleware will redirect the user to the named route 2step.confirm by default if the user is not verified. Lara2step comes with TwoStepController and default views for quick start. You can publish the views using `php artisan vendor:publish --tag="2step-views"` and customize them to your needs.

```
use Kohaku1907\Lara2step\Http\Controllers\TwoStepController;
use Illuminate\Support\Facades\Route;

Route::get('2fa-confirm', [TwoStepController::class, 'form'])
    ->name('2step.confirm');
Route::post('2fa-confirm', [TwoStepController::class, 'confirm']);
Route::post('2fa-resend', [TwoStepController::class, 'resend'])
    ->name('2step.resend');
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

914d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e82d7e45105593564c39b10cb921d4221654351eec3b6948cd220040d0b5a703?d=identicon)[kohaku1907](/maintainers/kohaku1907)

---

Top Contributors

[![kohaku1907](https://avatars.githubusercontent.com/u/6669745?v=4)](https://github.com/kohaku1907 "kohaku1907 (10 commits)")

---

Tags

laravel2fatwo-factortwo-stepkohaku1907laravel-2step2steplara2step

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/kohaku1907-lara2step/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)[laragear/two-factor

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

339785.3k8](/packages/laragear-two-factor)

PHPackages © 2026

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