lifeonscreen/nova-google2fa
lifeonscreen/nova-google2fa adds Google Two-Factor Authentication to Laravel Nova. It lets Nova users secure the admin panel with Google Authenticator, QR-code setup, and one-time codes, integrating 2FA into the login flow with minimal configuration.
Start by installing the package and publishing its config and migrations:
composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\<Package>\<PackageServiceProvider>"
php artisan migrate
Look first at:
config/user2fa.php or similar.User2Fa is bound or resolved.User2Fa class itself, especially its constructor and public methods.User model.The first day-to-day use case is enabling 2FA for a user: generate a secret, show a QR code, verify the first code, persist the secret, and issue recovery codes. In v1.0.1, the new override option means you can replace the package’s User2Fa implementation without forking the package. Use that only when you need custom secret generation, verification rules, recovery-code behavior, or storage semantics.
Use the default package flow first. Most Laravel 2FA packages follow this shape:
For the new override capability, create an application-level class that extends the package class:
namespace App\Support;
use Vendor\Package\User2Fa as BaseUser2Fa;
class User2Fa extends BaseUser2Fa
{
public function generateSecret(): string
{
// custom behavior, then fall back to parent where possible
return parent::generateSecret();
}
public function verify(string $code): bool
{
// custom verification rules
return parent::verify($code);
}
}
Then register it using the package’s new override option. Depending on the package, this will be either a config value, a container binding, or both:
// config/user2fa.php
'class' => App\Support\User2Fa::class,
or:
// AppServiceProvider::register()
$this->app->bind(
\Vendor\Package\User2Fa::class,
\App\Support\User2Fa::class
);
Prefer extending the original class and calling parent:: for behavior you do not need to change. If the package resolves User2Fa from the container, use a binding; if it reads a config class name, set the config value. Check the package service provider to confirm which mechanism applies.
Common integration patterns:
encrypted cast or the package’s built-in encryption.User2Fa subclass and asserts your override is used.User2Fa implementations per guard only if the package supports contextual resolution; otherwise keep one implementation and branch inside it.For day-to-day work, treat User2Fa as the main extension point and avoid editing vendor files. The v1.0.1 release is specifically useful when you need small behavioral changes without maintaining a fork.
php artisan config:clear after changing the override config. Cached config is the most common reason a custom User2Fa class is ignored.User2Fa, your subclass must accept and forward them.app()->make(User2Fa::class) resolves to your class. A config-only change will not help in that case.parent::verify() and add rules around it where possible.User2Fa class.class_exists(), parent class compatibility, and whether the package instantiates User2Fa directly with new.User2Fa behavior, v1.0.1 requires no code changes beyond a normal Composer update.How can I help you explore Laravel packages today?