fts / captcha
laravel 5 captcha package
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=5.4
- ext-gd: *
- illuminate/config: ~5.0
- illuminate/filesystem: ~5.0
- illuminate/hashing: ~5.0
- illuminate/support: ~5.0
- intervention/image: ~2.2
This package is auto-updated.
Last update: 2024-12-15 23:52:17 UTC
README
功能
- 生成验证码
- 检查验证码
安装
composer require fts/captcha
发布配置文件
php artisan vendor:publish
添加服务提供者
打开 config/app.php
并添加以下内容到 providers 数组:
fts\Captcha\CaptchaServiceProvider.php::class
用法
Route::any('captcha-test', function()
{
if (Request::getMethod() == 'POST')
{
$rules = ['captcha' => 'required|captcha'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
echo '<p style="color: #ff0000;">Incorrect!</p>';
}
else
{
echo '<p style="color: #00ff30;">Matched :)</p>';
}
}
$form = '<form method="post" action="captcha-test">';
$form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
$form .= '<p>' . captcha_img() . '</p>';
$form .= '<p><input type="text" name="captcha"></p>';
$form .= '<p><button type="submit" name="check">Check</button></p>';
$form .= '</form>';
return $form;
});
获取图片
captcha();
获取图片html
captcha_src();
获取图片url
captcha_img();