PHPackages                             hxm/2fa - 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. hxm/2fa

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

hxm/2fa
=======

A One Time Password Authentication package.

1.0.1(4y ago)19MITPHP

Since Oct 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/hoanxuanmai/2fa)[ Packagist](https://packagist.org/packages/hxm/2fa)[ RSS](/packages/hxm-2fa/feed)WikiDiscussions master Synced 1mo ago

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

2FA for Laravel
---------------

[](#2fa-for-laravel)

A One Time Password Authentication package.

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

[](#installation)

1. This package publishes a config/hxm2fa.php file. If you already have a file by that name, you must rename or remove it.
2. You can install the package via composer:

    ```
    composer require hxm/2fa
    ```
3. Run the migrations:

    ```
    php artisan migrate
    ```
4. You should publish the template views and the config/hxm2fa.php config file with:

    ```
    php artisan vendor:publish --provider=HXM2FA\ServiceProvider
    ```

- Default config file contents

    ```
    // ...
    return [
        'enabled' => true,
        'show_secret' => false,
        'route' => [
            'prefix' => 'user'
        ],

        'extend_layout' => 'layouts.app',

        'encrypt_secret' => true,

        /*customer QR style*/
        'qr_code' => [
            'size' => 192,
            'margin' => 0,
            'background' => [
                'red' => 255, //red the red amount of the color, 0 to 255
                'green' => 255, //green the green amount of the color, 0 to 255
                'blue' => 255 //blue the blue amount of the color, 0 to 255
            ],
            'fill' => [
                'red' => 45, //red the red amount of the color, 0 to 255
                'green' => 55, //green the green amount of the color, 0 to 255
                'blue' => 72 //blue the blue amount of the color, 0 to 255
            ],
        ]
    ];
    ```

Basic Usage
-----------

[](#basic-usage)

- First, add the HXM2FA\\TwoFactorAuthenticatable trait to your User model(s):

    ```

    use Illuminate\Foundation\Auth\User as Authenticatable;
    use HXM2FA\TwoFactorAuthenticatable;

    class User extends Authenticatable
    {
      use TwoFactorAuthenticatable;

      // ...
    }

    ```
- We provide a Facede with static functions that perform useful functions:

    ```

    use HXM2FA\Facades\HXM2FA;

      // ...

      /*to generate Secret*/
      $secret = HXM2FA::generate2FASecret();

      /*to generate QrCode html*/
      HXM2FA::getQrCode(string $company, string $holder, string $secret)

      /*to verify code*/
      HXM2FA::verifyCode(string $secret, string $code)

      /*To get instance of \PragmaRX\Google2FA\Google2FA */
      HXM2FA::getGoogle2FA();

      // ...

    ```

Author
------

[](#author)

[HoanXuanMai](https://github.com/hoanxuanmai)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

1664d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/253837bebf61531c6bb369dad0dd5e54136bd557b6583f058301ad837d5fa8dc?d=identicon)[hoanxuanmai](/maintainers/hoanxuanmai)

---

Top Contributors

[![hoanxuanmai](https://avatars.githubusercontent.com/u/47692574?v=4)](https://github.com/hoanxuanmai "hoanxuanmai (3 commits)")

---

Tags

laravelAuthentication2faTwo Factor Authenticationgoogle2fahxm

### Embed Badge

![Health badge](/badges/hxm-2fa/health.svg)

```
[![Health](https://phpackages.com/badges/hxm-2fa/health.svg)](https://phpackages.com/packages/hxm-2fa)
```

###  Alternatives

[pragmarx/google2fa-qrcode

QR Code package for Google2FA

12024.6M37](/packages/pragmarx-google2fa-qrcode)[laragear/two-factor

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

339785.3k8](/packages/laragear-two-factor)[stephenjude/filament-two-factor-authentication

Filament Two Factor Authentication: Google 2FA + Passkey Authentication

81158.7k4](/packages/stephenjude-filament-two-factor-authentication)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)

PHPackages © 2026

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