Laravel using captcha validation

install captcha dependence with composer

composer require mews/captcha

add the class interface into ‘providers’ section in config/app.php

Mews\Captcha\CaptchaServiceProvider::class,

define alias into the ‘alias’ section

'Captcha' => Mews\Captcha\Facades\Captcha::class,

execute command to create configuration file

php artisan vendor:publish

edit the config file accordingly in config/captcha.php

'default'   => [
    'length'    => 4,   // length of the captcha
    'width'     => 90, // width of the image
    'height'    => 32,  // height of the image
    'quality'   => 90,
],

the code to show the captcha in the form

<img src="{{captcha_src()}}" style="cursor: pointer" onclick="this.src='{{captcha_src()}}'+Math.random()">
This entry was posted in Development and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *