PHP code example of djimmy / laravel-captcha

1. Go to this page and download the library: Download djimmy/laravel-captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

djimmy / laravel-captcha example snippets


   // config/app.php
   'providers' => [
       Djimmy\Captcha\CaptchaServiceProvider::class,
   ];
   

   use Djimmy\Captcha\CaptchaService;

   public function showCaptcha(CaptchaService $captchaService)
   {
       return $captchaService->generateCaptcha();
   }
   

   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
       }
   }
   

   $captchaService->clearCaptcha();
   
bash
   php artisan vendor:publish --provider="Djimmy\Captcha\CaptchaServiceProvider"