这篇文章主要介绍了关于Laravel中使用验证码,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
预览

安装
在composer.json中添加验证码的引用
{
"require": {
"laravel/framework": "5.0.*",
"mews/captcha": "~2.0"
},
"minimum-stability": "dev"}或者是
composer require mews/captcha
接着就是运行下面的命令来更新库的依赖
composer update
或者
composer install
在windows系统中,必须在php.ini开启GD2 DLL拓展 php_gd2.dll,同时还必须开启php_fileinfo.dll和php_mbstring.dll
使用
在config/app.php 中注入验证码服务提供者。
'providers' => [
// ...
'Mews\Captcha\CaptchaServiceProvider',
]for Laravel 5.1+
'providers' => [
// ...
Mews\Captcha\CaptchaServiceProvider::class,
]找到aliases key 在 config/app.php。
'aliases' => [
// ...
'Captcha' => 'Mews\Captcha\Facades\Captcha',
]for Laravel 5.1+
'aliases' => [
// ...
'Captcha' => Mews\Captcha\Facades\Captcha::class,
]配置
可以自定义验证码的样式以及输入字符的数量
将配置文件拷贝到config目录下 $ php artisan vendor:publish
配置文件路径 config/captcha.php
return [ 'default' => [
'length' => 5,
'width' => 120,
'height' => 36,
'quality' => 90,
], // ...];具体的使用例子
@@##@@ @if ($errors->has('captcha')) {{ $errors->first('captcha') }} @endif
相关推荐:










