PHPackages                             darkghosthunter/laraguard - 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. darkghosthunter/laraguard

Abandoned → [laragear/two-factor](/?search=laragear%2Ftwo-factor)ArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

darkghosthunter/laraguard
=========================

On-premises 2FA Authentication for all your users out-of-the-box

v4.0.3(4y ago)264437.2k↓11.5%24[1 PRs](https://github.com/DarkGhostHunter/Laraguard/pulls)4MITPHPPHP ^8.0

Since Feb 11Pushed 4y ago12 watchersCompare

[ Source](https://github.com/DarkGhostHunter/Laraguard)[ Packagist](https://packagist.org/packages/darkghosthunter/laraguard)[ Docs](https://github.com/darkghosthunter/laraguard)[ Fund](https://paypal.me/darkghosthunter)[ Fund](https://ko-fi.com/DarkGhostHunter)[ RSS](/packages/darkghosthunter-laraguard/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (20)Used By (4)

Package superseeded by [Laragear/TwoFactor](https://github.com/Laragear/TwoFactor)
==================================================================================

[](#package-superseeded-by-larageartwofactor)

Please migrate to the new package.

---

Laraguard
=========

[](#laraguard)

Two-Factor Authentication via TOTP for all your users out-of-the-box.

This package enables authentication using 6 digits codes. No need for external APIs.

Requirements
------------

[](#requirements)

- [Laravel 8.83 or later](https://github.com/laravel/framework/blob/8.x/CHANGELOG-8.x.md#v8820-2022-02-01)
- PHP 8.0 or later.

> For older versions support, consider helping by sponsoring or donating.

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

[](#installation)

Fire up Composer and require this package in your project.

```
composer require darkghosthunter/laraguard

```

That's it.

### How this works

[](#how-this-works)

This package adds a **Contract** to detect if, after the credentials are deemed valid, should use Two-Factor Authentication as a second layer of authentication.

It includes a custom **view** and a **callback** to handle the Two-Factor authentication itself during login attempts.

Works without middleware or new guards, but you can go full manual if you want.

Usage
-----

[](#usage)

First, create the `two_factor_authentications` table by publishing the migration and migrating:

```
php artisan vendor:publish --provider="DarkGhostHunter\Laraguard\LaraguardServiceProvider" --tag="migrations"
php artisan migrate

```

This will create a table to handle the Two-Factor Authentication information for each model you want to attach to 2FA.

> If you're [upgrading from 3.0](UPGRADE.md), you should run a special migration.

Add the `TwoFactorAuthenticatable` *contract* and the `TwoFactorAuthentication` trait to the User model, or any other model you want to make Two-Factor Authentication available.

```
