PHP code example of mydaniel / laravel-captcha

1. Go to this page and download the library: Download mydaniel/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/ */

    

mydaniel / laravel-captcha example snippets


use Illuminate\Http\Request;
use MyDaniel\Captcha\Rules\Captcha;

public function submitForm(Request $request)
{
    $request->validate([
        'captcha_code' => ['

use Illuminate\Http\Request;

public function submitForm(Request $request)
{
    $request->validate([
        'captcha_code' => '

   namespace App\Captcha;

   use MyDaniel\Captcha\Contracts\CaptchaGeneratorContract;

   class QuestionGenerator implements CaptchaGeneratorContract
   {
       public function generate(array $config): array
       {
           return [
               'text' => 'What is the capital of France?',
               'key'  => 'paris',
           ];
       }
   }
   

   public function register()
   {
       $this->app->bind('captcha.generator.question', \App\Captcha\QuestionGenerator::class);
   }
   

   'profiles' => [
       'question' => [
           'driver' => 'question',
           'expire' => 120,
       ]
   ]
   
bash
   php artisan vendor:publish --provider="MyDaniel\Captcha\CaptchaServiceProvider"