djimmy/laravel-captcha
最新稳定版本:v1.0.4
Composer 安装命令:
composer require djimmy/laravel-captcha
包简介
A simple Laravel package for generating CAPTCHA images.
README 文档
README
About Laravel Captcha
Laravel Captcha is a simple and customizable package to integrate CAPTCHA functionality into your Laravel application. It provides an easy-to-use API for generating CAPTCHA codes and validating user inputs, helping to protect your application from bots and spam.
Features
- Generates customizable CAPTCHA images.
- Validates CAPTCHA inputs.
- Clears CAPTCHA sessions automatically.
- Easily integrates with Laravel applications.
Installation
Install the package using Composer:
composer require djimmy/captcha
Usage
-
Add the Service Provider (if not auto-discovered):
// config/app.php 'providers' => [ Djimmy\Captcha\CaptchaServiceProvider::class, ];
-
Publish the Config File:
php artisan vendor:publish --provider="Djimmy\Captcha\CaptchaServiceProvider" -
Generate a CAPTCHA Image:
In your controller:
use Djimmy\Captcha\CaptchaService; public function showCaptcha(CaptchaService $captchaService) { return $captchaService->generateCaptcha(); }
-
Validate CAPTCHA:
use Illuminate\Http\Request; use Djimmy\Captcha\CaptchaService; public function validateCaptcha(Request $request, CaptchaService $captchaService) { $isValid = $captchaService->validateCaptcha($request->input('captcha')); if ($isValid) { // CAPTCHA is valid } else { // CAPTCHA is invalid } }
-
Clear CAPTCHA:
$captchaService->clearCaptcha();
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-19