Using a verification code in Laravel

Source: Internet
Author: User
Tags aliases composer install

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.phpinject 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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.