uno-de-piera / simplerecaptcha by unodepiera

Simple recaptcha for laravel 4
45
0
2
Package Data
Maintainer Username: unodepiera
Maintainer Contact: unodepiera@uno-de-piera.com (unodepiera)
Package Create Date: 2013-08-21
Package Last Update: 2013-08-21
Language: PHP
License: Unknown
Last Refreshed: 2024-11-19 03:24:39
Package Statistics
Total Downloads: 45
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 2
Total Open Issues: 0

SimpleRecaptcha for Laravel 4

Installation

Open your composer.json and add the next code

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

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

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

	'providers' => array(
        //...
        'Unodepiera\Simplerecaptcha\SimplerecaptchaServiceProvider'
    )

Find the aliases key in app/config/app.php.

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

Publish config with this command.

$ php artisan config:publish unodepiera/simplerecaptcha

Example Usage SimpleRecaptcha

If you need keys recaptcha api go here.

Then set the config file with keys provides from recaptcha, the file config is saved in the directory app\config\packages\unodepiera\simplerecaptcha\config.php after publication.

Configuration

return array(


    /*
    | Set the public keys as provided by reCAPTCHA.
    */

    'public_key'    =>      '',


    /*
    | Set the public keys as provided by reCAPTCHA.
    */

    'private_key'   =>      '',


    /*
    | Set the the theme you want for the reCAPTCHA.
    | Options: red, white, clean and blackglass.
    */

    'theme'         =>      'clean',


    /*
    *
    *
    | Options buttons you want for reCAPTCHA.
    *
    *
    */

    /*
    | Set the the text you want for field text reCAPTCHA.
    */

    'textfield'     =>      'Write what you see',

    /*
    | Set the the text you want for field sound text reCAPTCHA.
    */

    'soundfield'    =>      'Write what you hear',


    /*
    | Set the the text you want for title button visual reCAPTCHA.
    */
    'visual_challenge'  =>      'Visual mode',


    /*
    | Set the the text you want for title button audio reCAPTCHA.
    */
    'audio_challenge'   =>      'Audio mode',


    /*
    | Set the the text you for title button reload reCAPTCHA.
    */
    'refresh_btn'   =>      'Ask two new words',


    /*
    | Set the the text you want for title button help reCAPTCHA.
    */
    'help_btn'  =>      'Help',


    /*
    | Set the message incorrect text reCAPTCHA.
    */
    'incorrect_try_again'   =>      'Incorrect. Try again',

);

Usage

Route::get("form", function()
{
    
    $html = "<form action='check' method='POST'>";
    $html.= Form::recaptcha();
    $html.= "<input type='submit'>";
    
    echo $html; 
});

Route::post("check", function()
{
    $rules =  array('recaptcha_response_field' => array('required', 'recaptcha'));
    $validator = Validator::make(Input::all(), $rules);
    if($validator->fails())
    {
        echo "fails";
    }else{
        echo "success";
    }
});

Visit me