New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

latrell/captcha

Captcha Package for Laravel 5
7,634 8
Install
composer require latrell/captcha
Latest Version:1.4
PHP:>=5.4.0
Laravel:5
Older releases:4
License:MIT
Last Updated:Mar 16, 2018
Links: GitHub  ·  Packagist
Maintainer: Latrell

For Laravel 4, please use the 1.1 branch!

Captcha for Laravel 5

A simple Laravel 5 service provider for including the Captcha for Laravel 5.

This library is not maintained for 3rd party use.

Preview

Captchas examples

Installation

composer require latrell/captcha dev-master

Usage

To use the Captcha Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this (only for Laravel 5.4 or below).

Find the providers key in config/app.php and register the Captcha Service Provider.

    'providers' => [
        // ...
        'Latrell\Captcha\CaptchaServiceProvider',
    ]

Find the aliases key in config/app.php.

    'aliases' => [
        // ...
        'Captcha' => 'Latrell\Captcha\Facades\Captcha',
    ]

Custom error messages. Add key captcha to resources/lang/[local]/validation.php

return [
	// ...
	'captcha' => '图片验证码不正确。',
];

Then publish the config file with php artisan vendor:publish. This will add the file config/latrell-captcha.php. This config file is the primary way you interact with Captcha.

Example Usage


    // [your site path]/app/Http/routes.php

    Route::any('/captcha-test', function()
    {

        if (Request::getMethod() == 'POST')
        {
            $rules =  ['captcha' => 'required|captcha'];
            $validator = Validator::make(Input::all(), $rules);
            if ($validator->fails())
            {
                echo '<p style="color: #ff0000;">Incorrect!</p>';
            }
            else
            {
                echo '<p style="color: #00ff30;">Matched :)</p>';
            }
        }

        $content = Form::open(array(URL::to(Request::segment(1))));
        $content .= '<p>' . HTML::image(Captcha::url()) . '</p>';
        $content .= '<p>' . Form::text('captcha') . '</p>';
        $content .= '<p>' . Form::submit('Check') . '</p>';
        $content .= '<p>' . Form::close() . '</p>';
        return $content;

    });

Related Packages

sayakb/captcha

Captcha Package for Laravel 4, Fork of mewebstudio/captcha

10,493 8
cahsowan/captcha

Fork of Captcha Package for Laravel 4

102 0
hyperbolaa/ylpay

银联pos通SDK在Laravel5.2封装包。

129 2
latrell/geohash

This package geohash for Laravel 5 support.

28,891 11

Version History

Version Released PHP Laravel License
1.4 >=5.4.0 5.* MIT
1.3 >=5.4.0 5.* MIT
1.2 >=5.4.0 5.* MIT
1.1 >=5.4.0 4.2.* MIT
1.0.2 >=5.3.0 4.1.* MIT