This article mainly introduces the use of Laravel in the verification code, has a certain reference value, now share to everyone, the need for friends can refer to
Preview
Installation
Add a reference to the composer.json
captcha in
{" require": { "laravel/framework": "5.0.*", "Mews/captcha": "~2.0" }, "minimum-stability": " Dev "}
or a
Composer require Mews/captcha
Next, run the following command to update the library's dependencies
Composer Update
Or
Composer Install
In a Windows system, you must php.ini
open the GD2 DLL extension php_gd2.dll
, and you must also turn on php_fileinfo.dll
andphp_mbstring.dll
Use
config/app.php
inject the Authenticode service provider in.
' Providers ' = [ //... ] Mews\captcha\captchaserviceprovider ',]
For Laravel 5.1+
' Providers ' = [ //... ] Mews\captcha\captchaserviceprovider::class,]
Found aliases key
in config/app.php
.
' Aliases ' = [ //... ] Captcha ' = ' Mews\captcha\facades\captcha ',]
For Laravel 5.1+
' Aliases ' = [ //... ] Captcha ' = Mews\captcha\facades\captcha::class, ]
Configuration
You can customize the style of the captcha and the number of input characters
Copy the configuration file to the config
directory
$ php artisan vendor:publish
configuration file path
config/captcha.php
return [ ' default ' = + [ ' length ' = 5, ' width ' = ' + ', ' height ' = 36, ' quality ' = +, ], //...];
Specific examples of use
<p class= "Form-group {{$errors->has (' Captcha ')? ' Has-error ': '} ' > <label for= "Captcha" class= "col-md-4 Control-label" > Captcha </label> <p class= "col-md-6" > <input id= "Captcha" class= "Form-control" name= "Captcha" > @if ($errors->has (' Captcha ')) <span class=" Help-block "> <strong>{{$errors->first (' captcha ')}}</strong> </span> @endif </p> </p>