2017 © Pedro Peláez
 

library simplecaptcha

simplecaptcha package for laravel 4

image

unodepiera/simplecaptcha

simplecaptcha package for laravel 4

  • Wednesday, December 11, 2013
  • by unodepiera
  • Repository
  • 1 Watchers
  • 0 Stars
  • 103 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Simple Captcha for Laravel 4

Installation

{
    "require": {
        "laravel/framework": "4.0.*",
        "unodepiera/simplecaptcha": "dev-master"
    },
    "minimum-stability": "dev"
}

Update your packages with composer update or install with composer install., (*1)

Usage

Find the providers key in app/config/app.php and register the Captcha Service Provider., (*2)

    'providers' => array(
        //...
        'Unodepiera\Simplecaptcha\SimplecaptchaServiceProvider',
    )

Find the aliases key in app/config/app.php., (*3)

    'aliases' => array(
        //...
        'Simplecaptcha'  => 'Unodepiera\Simplecaptcha\Facades\Simplecaptcha',
    )

Publish assets with this command., (*4)

$ php artisan asset:publish unodepiera/simplecaptcha, (*5)

Options captcha

You can set the following options for the captcha., (*6)

    $defaultOptions = array(
        "font"          =>  "PT_Sans-Web-Regular.ttf",
        "width"         =>  250,
        "height"        =>  140,
        "font_size"     =>  25,
        "length"        =>  6,
        "num_lines"     =>  "",
        "num_circles"   =>  "",
        "text"          =>  "",
        "expiration"    =>  600,
        "directory"     =>  "packages/unodepiera/simplecaptcha/captcha/",
        "dir_fonts"     =>  "packages/unodepiera/simplecaptcha/fonts/",
        "type"          =>  "alpha",
        "bg_color"      =>  "181,181,181",
        "border_color"  =>  "0,0,0"
    );
  • Font: type font for captcha, view folder public/fonts.
  • Num_lines: number lines you would for captcha.
  • Num_circles: number circles you would for captcha.
  • Expiration: number of seconds it will take to be removed captchas.
  • Directory: folder on save captchas.
  • Dir_fonts: directory on save the fonts.
  • Type: alpha or alphanum.

Example Usage

    Route::get("form", function()
    {

        $options = array(
            "width"         =>  280,
            "height"        =>  100,
            "font_size"     =>  28,
            "length"        =>  8,
            "num_circles"   =>  0,
            "num_lines"     =>  4,
            "expiration"    =>  600,
            "bg_color"      =>  "20,20,20"
        );

        $captcha = Simplecaptcha::captcha($options);
        return View::make("form", array("captcha" => $captcha));

    });
    Route::post("process", function()
    {
        $rules =  array('captcha' => array('required', 'captcha'));
        $validator = Validator::make(Input::all(), $rules);
        if($validator->fails())
        {

            echo "fails";

        }else{

            echo "success";

        }
    });

Now you can use the captcha in the view as follows:, (*7)



{{ Form::open(array('url' => 'process')) }} {{ Form::close() }}
{{ $captcha["img"] }}
{{ Form::label('captcha', 'Captcha') }} {{ Form::text('captcha') }}
{{ Form::submit('Success') }}

Visit me

The Versions

11/12 2013

dev-master

9999999-dev http://uno-de-piera.com

simplecaptcha package for laravel 4

  Sources   Download

The Requires

 

by Avatar unodepiera

laravel laravel 4 l4 captcha image captcha laravel 4 security laravel 4 unodepiera captcha