Looking to hire Laravel developers? Try LaraJobs

laravel-yandex-captcha maintained by fussraider

Description
Yandex captcha integration for Laravel
Last update
2025/09/24 23:26 (dev-main)
License
Links
Downloads
193

Comments
comments powered by Disqus

Laravel Yandex Captcha

A small package that will allow you to use Yandex SmartCaptcha in your Laravel app

Features

  • Easy to use Yandex SmartCaptcha Blade component
  • Easy to use Yandex SmartCaptcha validation

Installation

Install fussraider/laravel-yandex-captcha from composer

  composer require fussraider/laravel-yandex-captcha

Usage

  1. Add to your .env YANDEX_CAPTCHA_CLIENT_KEY YANDEX_CAPTCHA_SERVER_KEY

  2. Publish config

    php artisan vendor:publish --tag=yandex-captcha-config
    
  3. Add the Blade component to the form that needs a captcha

    <form action="{{route('login')}}" method="post">
        @csrf
        <input type="text" name="email">
        <input type="password" name="password">
        <x-yandex-captcha></x-yandex-captcha>
        <button type="submit">Send</button>
    </form>
    
  4. Add YandexCaptcha validation rule

    <?php  
    
    namespace App\Http\Requests;  
    
    use Fussraider\YandexCaptcha\Rules\YandexCaptcha;use Illuminate\Foundation\Http\FormRequest;  
    
    class LoginRequest extends FormRequest  
    {  
      public function rules(): array  
      {  
        return [  
          'email' => ['required', 'email'],  
          'password' => ['required', 'string', 'min:8'],  
          'smart-token' => ['required', new YandexCaptcha]  
        ];  
      }
    
      public function authorize(): bool  
      {  
        return true;  
      }  
    }
    

If you want to customize blade component you can publish it with

php artisan vendor:publish --tag=yandex-captcha-view