All Projects → mewebstudio → Captcha

mewebstudio / Captcha

Licence: other
Captcha for Laravel 5/6/7/8

Programming Languages

PHP
23972 projects - #3 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to Captcha

No Captcha
No CAPTCHA reCAPTCHA For Laravel.
Stars: ✭ 1,484 (-25.24%)
Mutual labels:  laravel, captcha
Larakube
Laravel app deployment for auto scaled Kubernetes cluster
Stars: ✭ 157 (-92.09%)
Mutual labels:  laravel
Identity Card
A simple proof of identity card of the people's Republic of China.
Stars: ✭ 154 (-92.24%)
Mutual labels:  laravel
Laravel Proximage
🌐 Laravel Proximage is a handy package for proxying images.
Stars: ✭ 156 (-92.14%)
Mutual labels:  laravel
Phphub
(Deprecated See - https://github.com/summerblue/phphub5 ) PHPHub is a Forum project written in Laravel 4.2, and it is also the project build up PHP & Laravel China community - http://phphub.org.
Stars: ✭ 1,846 (-7%)
Mutual labels:  laravel
Laravel Image Optimizer
[deprecated] Image optimizer for laravel
Stars: ✭ 156 (-92.14%)
Mutual labels:  laravel
Infinity Next
Infinity Next is an imageboard suite utilizing the Laravel framework.
Stars: ✭ 153 (-92.29%)
Mutual labels:  laravel
Online Ftp S3
Online FTP / Amazon S3 Filebrowser
Stars: ✭ 157 (-92.09%)
Mutual labels:  laravel
Laravel Blog Poetry All
Laravel诗词博客-匠心编程,热爱生活。喜欢就 Star 吧
Stars: ✭ 157 (-92.09%)
Mutual labels:  laravel
Opendominion
A text-based, persistent browser-based strategy game (PBBG) in a fantasy war setting
Stars: ✭ 155 (-92.19%)
Mutual labels:  laravel
Gocaptcha
A captcha library written in golang
Stars: ✭ 154 (-92.24%)
Mutual labels:  captcha
Schedule
Schedule is a package that helps tracking schedules for your models. If you have workers in a company, you can set schedules for them and see their availability though the time.
Stars: ✭ 155 (-92.19%)
Mutual labels:  laravel
Symposium
Management of proposals, bios, photos, etc. for conference speakers.
Stars: ✭ 157 (-92.09%)
Mutual labels:  laravel
Laravel Mobile Detect
Mobile detection within Blade templates
Stars: ✭ 154 (-92.24%)
Mutual labels:  laravel
Restful Api With Laravel Definitive Guide
Repository with the base code for the course "RESTful API with Laravel - Definitive-Guide"
Stars: ✭ 156 (-92.14%)
Mutual labels:  laravel
Laravel Keycloak Guard
🔑 Simple Keycloak Guard for Laravel / Lumen
Stars: ✭ 154 (-92.24%)
Mutual labels:  laravel
Decryptr
An extensible API for breaking captchas
Stars: ✭ 154 (-92.24%)
Mutual labels:  captcha
Spoon
Our simple Laravel boilerplate
Stars: ✭ 156 (-92.14%)
Mutual labels:  laravel
Searchable
A php trait to search laravel models
Stars: ✭ 1,923 (-3.12%)
Mutual labels:  laravel
Magutticms
Laravel 8 CMS for Web Artisans
Stars: ✭ 155 (-92.19%)
Mutual labels:  laravel

Captcha for Laravel 5/6/7

Build Status Scrutinizer Code Quality Latest Stable Version Latest Unstable Version License Total Downloads

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

for Laravel 4 Captcha for Laravel Laravel 4

Preview

Preview

Installation

The Captcha Service Provider can be installed via Composer by requiring the mews/captcha package and setting the minimum-stability to dev (required for Laravel 5) in your project's composer.json.

{
    "require": {
        "laravel/framework": "5.0.*",
        "mews/captcha": "~2.0"
    },
    "minimum-stability": "dev"
}

or

Require this package with composer:

composer require mews/captcha

Update your packages with composer update or install with composer install.

In Windows, you'll need to include the GD2 DLL php_gd2.dll in php.ini. And you also need include php_fileinfo.dll and php_mbstring.dll to fit the requirements of mews/captcha's dependencies.

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.

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

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

for Laravel 5.1+

    'providers' => [
        // ...
        Mews\Captcha\CaptchaServiceProvider::class,
    ]

Find the aliases key in config/app.php.

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

for Laravel 5.1+

    'aliases' => [
        // ...
        'Captcha' => Mews\Captcha\Facades\Captcha::class,
    ]

Configuration

To use your own settings, publish config.

$ php artisan vendor:publish

config/captcha.php

return [
    'default'   => [
        'length'    => 5,
        'width'     => 120,
        'height'    => 36,
        'quality'   => 90,
        'math'      => true,  //Enable Math Captcha
        'expire'    => 60,    //Stateless/API captcha expiration
    ],
    // ...
];

Example Usage

Session Mode:

    // [your site path]/Http/routes.php
    Route::any('captcha-test', function() {
        if (request()->getMethod() == 'POST') {
            $rules = ['captcha' => 'required|captcha'];
            $validator = validator()->make(request()->all(), $rules);
            if ($validator->fails()) {
                echo '<p style="color: #ff0000;">Incorrect!</p>';
            } else {
                echo '<p style="color: #00ff30;">Matched :)</p>';
            }
        }
    
        $form = '<form method="post" action="captcha-test">';
        $form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
        $form .= '<p>' . captcha_img() . '</p>';
        $form .= '<p><input type="text" name="captcha"></p>';
        $form .= '<p><button type="submit" name="check">Check</button></p>';
        $form .= '</form>';
        return $form;
    });

Stateless Mode:

You get key and img from this url http://localhost/captcha/api/math and verify the captcha using this method:

    //key is the one that you got from json response
    // fix validator
    // $rules = ['captcha' => 'required|captcha_api:'. request('key')];
    $rules = ['captcha' => 'required|captcha_api:'. request('key') . ',math'];
    $validator = validator()->make(request()->all(), $rules);
    if ($validator->fails()) {
        return response()->json([
            'message' => 'invalid captcha',
        ]);

    } else {
        //do the job
    }

Return Image

captcha();

or

Captcha::create();

Return URL

captcha_src();

or

Captcha::src('default');

Return HTML

captcha_img();

or

Captcha::img();

To use different configurations

captcha_img('flat');

Captcha::img('inverse');

etc.

Based on Intervention Image

^_^

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].