Download the PHP package timehunter/laravel-google-recaptcha-v2 without Composer
On this page you can find all versions of the php package timehunter/laravel-google-recaptcha-v2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timehunter/laravel-google-recaptcha-v2
More information about timehunter/laravel-google-recaptcha-v2
Files in timehunter/laravel-google-recaptcha-v2
Package laravel-google-recaptcha-v2
Short Description Laravel Package for google reCAPTCHA v2
License MIT
Homepage https://github.com/RyanDaDeng/laravel-google-recaptcha-v2
Informations about the package laravel-google-recaptcha-v2
Laravel Package for Google reCAPTCHA v2
Welcome all tickets (features/questions/bugs/improvements), I will respond to all tickets within 48 hours.
This is a package for Google reCAPTCHA v2.
If you want to use v3, please go to: https://github.com/RyanDaDeng/laravel-google-recaptcha-v3
DEMO
Checkbox
Invisible - hidden
Invisible - Inline
Corner
Description
A Laravel package for Google reCAPTCHA v2.
If you want to make your own font-end template, you have full access to modify template file, so you can customise your own template by reading through Google official guide for either invisible badge or inline checkbox. https://developers.google.com/recaptcha/docs/display
Features
- Support invisible, corner and inline badge style
- Support multiple reCAPTCHA on the same page for different forms
- Support multiple actions to be placed on the same page
- Support custom implementation on config interface
- Support custom implementation on request method interface
- Support custom implementation on Template file
Requirement
This package requires the following dependencies:
-
Laravel 5.x
-
If you want to use Validation Class your Laravel version needs to be >= 5.5
-
php > 5
- Please ensure that you have read basic information from Google reCAPTCHA v2.
Installation
Via Composer
If your Laravel framework version <= 5.4, please register the service provider in your config file: /config/app.php, otherwise please skip it.
And also
If your Laravel framework version is >= 5.5, just run the following command to publish config.
Optional: if you want to modify or customise your own template, you can publish a default view first, and change 'template' in config file:
After installation, you should see a googlerecaptchav2/template.blade under views folder and googlerecaptchav2.php in your app/config folder.
Basic Usage
Setting up your Google reCAPTCHA details in config file
Please register all details on host_name, site_key, secret_key and site_verify_url.
For more details please check comments in config file.
Display reCAPTCHA v2
Note: for styling with reCAPTCHA v2 badge, the official site does not support it. You can still customise it on its div element if you want.
Blade
Include div with an ID inside your form, e.g.
Include Template script in your bottom/header of your page, e.g.
Example Usage
The backend request will receive a value for 'g-recaptcha-response', please take a look at Sample Use Case and Facade usage sections.
Badge Display
Importance: you can always make your own template, just assign your template in config:
Checkbox
-
Go to config file, and set
- Badge will be displayed as checkbox format within the form.
Invisible - inline
-
Set size as invisible
- Set badge as inline or bottomright or bottomleft
Invisible - hidden
-
Set size as invisible
- Modify your div with style display:none
- Refer to Google official site: https://developers.google.com/recaptcha/docs/faq , you need to include the following text:
Corner
-
Set size as invisible
- Set badge as bottomright/bottomleft
Validation Class (Only support Laravel >= 5.5)
You can use provided Validation object to verify your reCAPTCHA.
Facade Usage
You can also directly use registered service by calling the following method.
- verifyResponse() which accepts the token value from your form. This return Google reCAPTCHA Response object.
Example Usage
Sample Use Case
-
Register your action in config, also enable score and set up your own site key and secret key:
-
Register two routes in web.php
-
Create two functions in controller:
- Create your form in index.blade.php:
Advanced Usage
Custom implementation on Template
After publish views, a blade file created under googlerecaptchaV2, you can customise it and change template value in config file, e.g. if your template is saved in resources/views/test/template, you should put values as below:
Custom implementation on Config
For some users, they might store the config details in their own storage e.g database. You can create your own class and implement:
Remember to register it in your own service provider
Custom implementation on Request method
The package has two default options to verify: Guzzle and Curl, if you want to use your own request method, You can create your own class and implement
Remember to register it in your own service provider
Contributers
@markheramis
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
MIT. Please see the license file for more information.