1、首先要在你的Laravel项目中安装Google验证器插件、二维码生成器插件,执行命令如下:
# Google验证器插件安装命令:
composer require "earnp/laravel-google-authenticator:dev-master"
# 二维码生成器:
composer require simplesoftwareio/simple-qrcode 1.3.*
安装完成后,会自动在composer.json文件中加入版本信息,如果没有成功,手动添加,再执行,如下图所示:
2、扩展安装后,结构如下图所示:
3、安装完成后,在config/app.php
中注册服务提供者同时注册下相应门面,代码如下:
'providers' => [ /* * Laravel Framework Service Providers... */ ... ... ... ... App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, // Google验证器 Earnp\GoogleAuthenticator\GoogleAuthenticatorServiceprovider::class, // 二维码生成器 SimpleSoftwareIO\QrCode\QrCodeS