Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install the verification code package in laravel

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Xiaobian shares with you how laravel installs the Captcha package. I believe most people still don't know much about it, so share this article for your reference. I hope you will gain a lot after reading this article. Let's find out together!

Laravel installation Captcha package method: 1. Login URL packagist.org;2. Find laravel captcha, find "mews/captcha";3. According to the use method on packagist to achieve the installation of Captcha.

Operating environment: Windows 7 system, Laravel 5.7 version, DELL G3 computer.

Laravel -Captcha (captcha)

I feel the use of a relatively good Captcha package, take it out to share, fool tutorial, big brother do not spray.: smile: :smile: :smile:

Installation steps:

First, log in to packagist.org to find laravel captcha, find mews/captcha, and install Captcha step by step according to the usage method on packagist.

composer install: composer require mews/captcha

Register providers (config/app.php) and append the following code to the end of this array:

Mews\Captcha\CaptchaServiceProvider::class,

Register aliases (config/app.php) and append the following code to the end of this array:

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

To generate the configuration file, enter the following command on the Composer command line:

php artisan vendor:publish

Enter config/captcha.php file, modify default array to modify style, quantity and size of Captcha.

'default' => ['length' => 5,'width' => 100,'height' => 34,'quality' => 90,],

Pages used:

Overwrite AuthController login authentication method and customize prompt information:

First, introduce the following code:

use Illuminate\Http\Request;

Rewrite the validateLogin method:

protected function validateLogin(Request $request){ $this->validate($request, [ $this->loginUsername() => 'required', 'password' => 'required', 'captcha' => 'required|captcha', ],[ 'captcha.required' => trans('validation.required'), 'captcha.captcha' => trans('validation.captcha'), ]); }

Download and switch font library:

First you need to download the font library

After downloading, copy the src/zh-CN folder in the archive to the resources/lang folder in the project directory.

Modify config-> app.php file as follows:

'locale' => 'zh-CN',

Since captcha has no Chinese explanation in the Chinese package, you need to add Chinese explanation manually. The specific operation is as follows:

Open resources/zh-CN/validation.php and append the following key pairs to the total array:

'captcha' => ':attribute is incorrect. ',

Append the following key-value pairs to the attributes array:

'captcha' => 'Captcha', above is "laravel how to install Captcha package" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report