Laravel 验证码
验证码的安装
我们通过 Composer 安装 Captcha 扩展包
composer require mews/captcha
# 可以指定想要安装的版本
composer require mews/captcha:版本号
使用配置
使用Captcha服务提供者之前还需要在config/app.php
中注册服务提供者:
# 在服务提供者中添加此项
'providers' => [
Mews\Captcha\CaptchaServiceProvider::class,
]
# 同时注册下相应门面:
'aliases' => [
'Captcha' => Mews\Captcha\Facades\Captcha::class,
]
# 发布配置
php artisan vendor:publish
模板中调用
常用方法
# 返回url
{!! captcha_src() !!}
# 返回 img 的html
{!! captcha_img () !!}
# 生成配置
php artisan vendor:publish
模板中
效果
点击更换验证码图片
验证码的输入验证
解决验证提示中文
方案1 了解
方案2 推荐
效果