tsoftware / captcha
一个简单快速的验证码生成器
v1.0
2015-12-23 20:07 UTC
Requires
- php: >=5.5.9
- illuminate/session: 5.1.*
- illuminate/support: 5.1.*
This package is not auto-updated.
Last update: 2024-09-18 18:36:40 UTC
README
##介绍 Tsoftware\Captcha 是 Laravel 5 中的一个验证码生成器!
##使用方法
composer require tsoftware/captcha
首先,在 app/config.php 中添加
'providers' => [ Tsoftware\Captcha\CaptchaProvider::class, ] 'aliases' => [ 'Captcha' => Tsoftware\Captcha\CaptchaFacade::class, ]
例如,在 app/Http/Controllers/Auth/AuthController.php 文件中
use Captcha; public function getCaptcha() { return Captcha::output('_captcha', 100, 40, 4); } protected function validator(array $data) { $validator = Validator::make($data, [ 'name' => 'required|min:5|max:20', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:5', 'captcha' => 'required', ]); $validator->after(function($validator) use ($data){ if (!Captcha::check($data['captcha'])) { $validator->errors()->add('captcha', 'Wrong captcha code!'); } }); return $validator; }
##反馈
- 邮件(admin@yantao.info)
- QQ: 1065317290
- 博客: Yantao.Info
- GitHub: tsoftware-org/captcha