Download the PHP package timehunter/laravel-google-recaptcha-v3 without Composer

On this page you can find all versions of the php package timehunter/laravel-google-recaptcha-v3. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
timehunter/laravel-google-recaptcha-v3
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package laravel-google-recaptcha-v3

Laravel Package for Google reCAPTCHA V3

Latest Version on Packagist Total Downloads Coverage Status Build StyleCI

A star would be a nice encouragement. ^.^

Latest features:

If you want to use v2, please go to: https://github.com/RyanDaDeng/laravel-google-recaptcha-v2

If you only need to use Vue component, feel free to copy it.

Table of Contents

  1. Installation
  2. Configurations
  3. Facade Usage
  4. Blade Usage
  5. Ajax Usage
  6. Vue Usage
  7. Validation
  8. Advanced Usage
  9. Contributors

Demo code: https://github.com/RyanDaDeng/laravel-google-recaptcha-v3/wiki/Simple-Demo

DEMO

Invisible - hidden

Inline

Corner

Description

Google reCAPTCHA v3 is a new mechanism to verify whether the user is bot or not.

reCAPTCHA v3 is intended for power users, site owners that want more data about their traffic, and for use cases in which it is not appropriate to show a challenge to the user.

For example, a registration page might still use reCAPTCHA v2 for a higher-friction challenge, whereas more common actions like sign-in, searches, comments, or voting might use reCAPTCHA v3.

Please check Google site: https://developers.google.com/recaptcha/docs/faq

Features

Requirement

This package requires the following dependencies:

Installation

Demo code: https://github.com/RyanDaDeng/laravel-google-recaptcha-v3/wiki/Simple-Demo

Via Composer

If your Laravel framework version <= 5.4, please register the service provider under 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.

For vue component:

After installation, you should see a googlerecaptchav3.php in your app/config folder, and vue component under js/components/googlerecaptchav3 folder.

For multi lang:

A lang folder will be created under /resources/lang/vendor/GoogleReCaptchaV3/*

Configurations

Setting up your Google reCAPTCHA details in config file

Please register all details in config for host_name, site_key, secret_key and site_verify_url.

Register credentials in .env:

`

Specify your Score threshold and action in 'setting', e.g.

Note: if you want to enable Score Comparison, you also need to enable is_score_enabled to be true.

For score comparison, all actions should be registered in googlerecaptchav3 config file under 'setting' section.

For more details please check comments in config file.

Facade Usage

You can directly use registered facade service by calling the following methods.

  • setAction() is optional only if you want to verify if the action is matched.
  • verifyResponse() which accepts the token value from your form. This returns Google reCAPTCHA Response object.
  • setScore() is optional only if you want to manually verify the score.

Example Usage

If you manually assign a value to setScore($score), the code will fully skip your config file and force to check the score.

Validation Class (Only support Laravel >= 5.5)

You can use provided Validation object to verify your reCAPTCHA.

  • $actionName: if its NULL, the package won't verify action with google response.

Blade Usage

Display reCAPTCHA v3

Add Google API script

Include the API script at the bottom of your layout page

Consent Security Policy - Nonce

To add a nonce for content security, pass a params array with your pages nonce.

Running script on every page (optional)

It's recommended to include reCAPTCHA v3 on every page which can help you get the most context about interactions for analytics. You just need to enable the config:

If the page has not detected any Action or duplicate google script, the background mode will be enabled.

Form & Action

There are three methods to populate the reCAPTCHA within the form.

  • render() and renderOne() can be placed in anywhere but before init()
  • renderField() needs always to be placed within your form.

Method one - render():

Method two - renderOne():

Method three - renderField():

Badge Display for Form & Action

If your settings were not reflected, please run php artisan config:cache to clear cache.

Inline

  1. Go to config file, and set

  2. Badge will be displayed as inline format within the form.

Invisible

  1. Set inline as true as well
  2. Modify your div with style display:none
  3. Refer to Google official site: https://developers.google.com/recaptcha/docs/faq , you need to include the following text:

Corner

  1. Set inline as false
  2. Your badge will be shown in the bottom right side.

Custom

  1. Set inline as true
  2. Do Styling/CSS on its div element

Ajax Usage - Refresh reCAPTCHA Response

The package provides two handy Javascript functions for you to get recaptcha response and refresh recaptcha as needed.

  • refreshReCaptchaV3(fieldId,actionName) - this function will reset the response whenever your ajax response is returned.

  • getReCaptchaV3Response - this function helps you to get recaptcha response by id

For example:

`

Vue Usage (Package version >= 2.2.0)

The package provides a lightweight vue component. You need to publish the vue component before playing around it.

Step 1 Publish vue component:

The file will be created under js/components/googlerecaptchav3/GoogleReCaptchaV3.vue, you have full control and modification ability on this file.

Step 2 Import vue component and Register reCAPTCHA v3 SiteKey

A BIG thanks to @Fluxlicious who improved the vue component.

The Blade way is no longer useful if you use Vue. We need to manage to assign site key by ourselves. The component supports props below:

Supported: siteKey, id, inline and action, check the original file to see the details.

`

There are two ways you can bind site key to the component.

Use prop

`

Please remember to refresh token every time you submit the form if needed:

`

or Add site key directly into GoogleReCaptchaV3 component

Alternatively, I believe most of cases your site key will never be changed, so you could just modify the original published component to have sitekey hard-coded in.

For instance, open published file and find code below: `

Advanced Usage

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

Contributors

Thank you for the following contributors, You guys are the BEST!

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.


All versions of laravel-google-recaptcha-v3 with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package timehunter/laravel-google-recaptcha-v3 contains the following files

Loading the files please wait ....