Download the PHP package recaptcha-lib/recaptcha without Composer

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

PHP Library for reCAPTCHA Google's API

Build status: Build Status Latest Stable Version Total Downloads Latest Unstable Version

This is PHP library that handle Google's reCAPTCHA API, you can easy implement it into your site or app and be able to set custom configurations and options to display the widget as you want.

Library Features

Quick Installation via composer

You can find this library at Composer/Packagist.

Optional Manual Install

If you don't use composer you'll have to download the latest release of this library and unpack it within your project folder.

Once you've done it, you'll need only those files within the ReCaptcha folder you can get rid of others files and samples in there, if you want to.

The reCAPTCHA Libray comes with an Autoloader that you can include in the top of your page. By using the autoloader there is no need of including files manually, see an example below:

Displaying reCAPTCHA

Display default options and theme.

Display a Standard Theme, your API Keys and options from a config file.

To display a different theme and language straightforward.

Samples

ReCaptcha-lib provides many ways to display and configure a reCAPTCHA widget. A theme can be set by a given name e.g: Captcha::displayHTML('clean'). You can find all Standard Theme names in https://developers.google.com/recaptcha/docs/customization.

displayHTML(); displayHTML('white'); displayHTML('clean'); displayHTML('custom');
image image image image

NOTE: When using a custom theme, as you can see above, the template is displayed in pure HTML so you need to provide a CSS to display a custom theme properly to your users. The widget elements are wrapped within a div container default ID recaptcha_widget but you can change this ID using the option custom_theme_widget

You can find more examples how to implement reCAPTCHA in examples folder.

Verifying reCAPTCHA User's Answer

The Library has a method Captcha::isValid() to check the user's answer when performing a form post. It's easy to implement.

Basic Verify

The method Captcha::isValid() takes an action only when its encountered a REQUEST_METHOD POST, so you can set in the same page that method Captcha::displayHTML()

Options

Custom options can be set by passing an array of values to Captcha::displayHTML()

Custom theming and language of the widget

Configuration

Changing Widget Language

Set a language in object constructor as a first parameter.

Run reCAPTCHA Over SSL

When using SSL site, to avoid getting browser certificate warnings when you display reCAPTCHA set a second parameter to TRUE in object constructor.

NULL set the language to default system built-in translation. TRUE enable call API using https://

Timeout

The Library has a timeout when performing a request server API to verify the user's answer. The default timeout value is 10. If you want to change.

Global Config

If you want instead of passing arrays all the time into your widget you might set a Global configuration by creating an external file with all options and configurations to be read globally.

Sample File: captcha_config.php.

Then pass its path to the method: Captcha::setConfig($path).

Internationalization

This library has two different approaches to display reCAPTCHA widget in a different language to the user's screen.

Built-in Language

It's a default Google's reCAPTCHA API language translation, so the widget strings are shown according the user's browser language preference, whether user's language is not in the system built-in the English will be used instead.

Custom language

If you are using Custom Theme Template you must set a customized translation as well, despite using any Standard Theme that you need to display your reCAPTCHA widget in a different language which is not available in system built-in you can use your own translation strings.

This library offers you a simple way to customize translation strings, within a folder I18n there's a few languages already translated in there. If you want to use one of them just pass the language code as first parameter to the object constructor. See examples in section configuration above.

Even if your language is not in there, you have two options to get your widget translated.

Create a Language File

You might translate the widget strings by writing a file recaptcha.lang.[lang_code].php take a look one of them within I18n folder as a reference*, place it somewhere in your dir, then tell to the library where it is by passing its path as a second parameter to the method Captcha::setTranslation(lang_code, path).

This will point to a file: /optional/path/to/file/lang/recaptcha.lang.fr.php

NOTE: your custom Lang file must be named as recaptcha.lang.[lang_code].php where lang_code is your language abbreviation e.g. 'French' is fr.

Optional

Instead of create an external Lang file you may also translate your widget strings by passing an array to the custom_translations option:

Collaborate If you want to translate a language file and collaborate, fork this project do it and send us a pull request.

Theme Customization

There are a few Standard Theme ready to go with, as written in Custom Theming Docs.

Documentation

This library has a better documentation generated by PHPDoc you can take a look at Documentation Page.

Bugs

Have you found a bug? Please open a new issue.

Author

Adriano Rosa @adrianorosa

Notes

In order to start using this library you must generate your reCAPTCHA's API Key from Google's reCAPTCHA site.

License

This software is licensed under the MIT License. Please read LICENSE for information on the software availability and distribution.


All versions of recaptcha with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 recaptcha-lib/recaptcha contains the following files

Loading the files please wait ....