Looking to hire Laravel developers? Try LaraJobs

laravel-captcha maintained by djimmy

Description
A simple Laravel package for generating CAPTCHA images.
Last update
2024/12/20 14:00 (dev-main)
License
Links
Downloads
8

Comments
comments powered by Disqus

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

  1. Add the Service Provider (if not auto-discovered):

    // config/app.php
    'providers' => [
        Djimmy\Captcha\CaptchaServiceProvider::class,
    ];
    
  2. Publish the Config File:

    php artisan vendor:publish --provider="Djimmy\Captcha\CaptchaServiceProvider"
    
  3. Generate a CAPTCHA Image:

    In your controller:

    use Djimmy\Captcha\CaptchaService;
    
    public function showCaptcha(CaptchaService $captchaService)
    {
        return $captchaService->generateCaptcha();
    }
    
  4. 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
        }
    }
    
  5. 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.