Download the PHP package uestla/recaptcha-control without Composer

On this page you can find all versions of the php package uestla/recaptcha-control. 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?

Informations about the package recaptcha-control

reCAPTCHA for Nette Framework

Adds the reCAPTCHA control to Nette Framework forms.

Documentation

  1. Installation
  2. Configuration
  3. Usage
  4. Requester
  5. AJAX
  6. Invisible reCAPTCHA
  7. Testing

Installation

For easy installation use Composer:

Also don't forget to include the official JavaScript library:

Are you using AJAX? Then you may want to use library asset instead - see more.

Configuration

To be able to use the reCAPTCHA control in your forms just register the DI extension in your config.neon:

Parameters:

Parameter Type Default value Required Meaning
siteKey string | Nette\DI\Statement ~ YES The site key you obtain in your Google Account
secretKey string | Nette\DI\Statement ~ YES The secret key you obtain in your Google Account
methodName string "addReCaptcha" NO Extension method name you'll be calling upon your forms to add the control, e.g. $form->addReCaptcha(...)
requester string "CurlRequester" NO Name of the class or service which sends requests to the Google validation API. The default CurlRequester needs PHP cURL extension to run properly. Read more about requesters here.

Usage

Form

To actually add reCAPTCHA to your form just call

Please note that the validation rule is added automatically so you don't need to call any addRule() at all.

Template

You can then render the control in your Latte template using both macro and n:attr approach:

And there she goes! :-)

reCAPTCHA

Requester

Requester is a layer for sending HTTP requests. It comes handy when your production environment does not meet the default requirements (cURL extension etc.).

You can change the default requester by setting the requester key in configuration. The value can be either a class name or a name of another service (see details below).

  1. CurlRequester

    This is the default one since requester value is optional in configuration.

    It uses PHP cURL extension. If you want to set any CURLOPT_* value for the requests you have to create the service aside and pass these options to the constructor:

    As you can see in the example it is possible to use all CURLOPT_* constants as string keys (they are converted internally).

  2. SimpleRequester

    Calls file_get_contents() with stream context.

  3. GuzzleRequester

    If you're already using the Guzzle HTTP Client in your application, this requester may come handy:

    If you're using multiple clients it is better to define the requester as a service aside:

  4. Custom requester

    You can also implement your own requester. Just make sure it implements the ReCaptchaControl\Http\Requester\IRequester interface.

    It basically requires a single public function post(string $url, array $values = []): string method which takes URL, performs a HTTP POST request with given $values and returns body of the response as a string. In case of a failure, ReCaptchaControl\Http\Requester\RequestException should be thrown.

    You can then use it the same way as above:

    or when you have some dependencies:

AJAX

When a snippet containing reCAPTCHA control gets updated, the reCAPTCHA itself needs to be re-rendered.

If you're using the nette.ajax.js, you may want to use the assets/recaptcha.ajax.js script.

You can install it via bower:

IMPORTANT: The explicitely. So please be careful not to loaded by yourself as well.

Invisible reCAPTCHA

You can also use this library for Invisible reCAPTCHA. The backend part stays the same so it only needs proper configuration in the frontend. To see it in action you can visit https://kesspess.cz/recaptcha/invisible and the code in tests.

Tests & CI

Automated tests

This library uses Nette Tester for automated testing and PHPStan for static analysis. For running them yourself simply run

Manual testing

You may have noticed the https://kesspess.cz/recaptcha.

To get it to work on your local machine, do following:

  1. copy config/local.neon.template to config/local.neon
  2. fill reCAPTCHA keys properly in config/local.neon
  3. run composer install
  4. run bower install

After that you should be able to run it via your local web server.

The form definitions are in TestPresenter.

Individual example templates are located in presenters/templates directory.


All versions of recaptcha-control with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
nette/di Version ^3.0
nette/http Version ^3.0
nette/forms Version ^3.0
nette/utils Version ^3.0 || ^4.0
nette/php-generator Version ^3.0 || ^4.0
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 uestla/recaptcha-control contains the following files

Loading the files please wait ....