2017 © Pedro Peláez
 

laravel-plugin g-recaptcha

Easily add google recaptcha

image

astritzeqiri/g-recaptcha

Easily add google recaptcha

  • Wednesday, August 9, 2017
  • by astritzeqiri
  • Repository
  • 1 Watchers
  • 0 Stars
  • 41 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

StyleCI Total Downloads, (*1)

Google recaptcha for laravel

Easily add google recaptcha, (*2)

Requirements

  • PHP >=5.4
  • Laravel >= 5.0
  • GuzzleHttp >= 5.3

Installation

Add astritzeqiri/g-recaptcha to your composer.json file:, (*3)

"require": {
    "astritzeqiri/g-recaptcha": "~1.0"
}

And do:, (*4)

$ composer update

Or get composer to install the package:, (*5)

$ composer require astritzeqiri/g-recaptcha

Configuration

Now you go and generate a new Google recaptcha on the link below:, (*6)

Google Recaptcha Generate., (*7)

Then you go to your .env file and set these variables, (*8)

# If you want to disable captchas put this to false by default this is true.
GRECAPTCHA_ENABLED=true

# The google recaptcha site key
GRECAPTCHA_KEY=SITE_KEY

# The google recaptcha secret key
GRECAPTCHA_SECRET=SECRET_KEY

You can also change these variables on the config file on config/grecaptcha.php file., (*9)

return [
    'enabled' => env("GRECAPTCHA_ENABLED", true),
    'site_key' => env("GRECAPTCHA_KEY"),
    'secret_key' => env("GRECAPTCHA_SECRET"),
];

Registering the Package

Register the service provider within the providers array found in app/config/app.php:, (*10)

'providers' => array(
    // ...
    AstritZeqiri\GRecaptcha\GRecaptchaServiceProvider::class
)

Then you need to add GRecaptcha class within the aliases array found in app/config/app.php:, (*11)

'aliases' => array(
    // ...
    'GRecaptcha' => AstritZeqiri\GRecaptcha\GRecaptcha::class,
)

Then you run php artisan vendor:publish to publish the start_captchas script and also the recaptcha config file., (*12)

$ php artisan vendor:publish

Usage

First of all you need to call the grecaptcha scripts on the footer. The scripts are rendered only if you have an active captcha somewhere on you html., (*13)

// in blade.php files
{!! \GRecaptcha::renderScripts() !!}

// or in .php files

Basic Example

Now to render a new GRecaptcha you call the render method., (*14)

// by default it echo's it out
GRecaptcha::render();

// if you want to save the html in a variable you call 
$grecaptchaHtml = GRecaptcha::render([], false);

If you want to get a new recaptcha instance:, (*15)

$grecaptcha = GRecaptcha::generate();

// to render it you call
$grecaptcha->renderHtml();

// if you dont want it to be rendered but store the html you call
$grecaptchaHtml = $grecaptcha->build();

Validation

When you validate a form to validate the recaptcha you use the rule grecaptcha, (*16)

$validator = Validator::make($inputs,
    ['g-recaptcha-response' => 'required|grecaptcha']
);

License

MIT, (*17)

The Versions

09/08 2017

dev-master

9999999-dev https://github.com/astritzeqiri/g-recaptcha

Easily add google recaptcha

  Sources   Download

MIT

The Requires

 

laravel authentication google recaptcha g-recaptcha

08/01 2017

dev-analysis-8wgpm4

dev-analysis-8wgpm4 https://github.com/astritzeqiri/g-recaptcha

Easily add google recaptcha

  Sources   Download

MIT

The Requires

 

laravel authentication google recaptcha g-recaptcha

31/08 2016

1.0.3

1.0.3.0 https://github.com/astritzeqiri/g-recaptcha

Easily add google recaptcha

  Sources   Download

MIT

The Requires

 

laravel authentication google recaptcha g-recaptcha

31/08 2016

1.0.2

1.0.2.0 https://github.com/astritzeqiri/g-recaptcha

Easily add google recaptcha

  Sources   Download

MIT

The Requires

 

laravel authentication google recaptcha g-recaptcha

26/08 2016

1.0.1

1.0.1.0 https://github.com/astritzeqiri/g-recaptcha

Easily add google recaptcha

  Sources   Download

MIT

The Requires

 

laravel authentication google recaptcha g-recaptcha

26/08 2016

1.0.0

1.0.0.0 https://github.com/astritzeqiri/g-recaptcha

Easily add google recaptcha

  Sources   Download

MIT

The Requires

 

laravel authentication google recaptcha g-recaptcha