djimmy / laravel-captcha
A simple Laravel package for generating CAPTCHA images.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=8.0
- illuminate/support: ^9.0|^10.0
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.