Skip to content

Commit

Permalink
Add context to installation instructions
Browse files Browse the repository at this point in the history
Additional clarification of what Composer is, how to install without it, and the development dependencies.
  • Loading branch information
rowan-m committed Jul 5, 2015
1 parent e90c632 commit afdcb02
Showing 1 changed file with 53 additions and 21 deletions.
74 changes: 53 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,59 @@ with reCAPTCHA.

## Installation

Use [Composer](https://getcomposer.org/) to install the library. Either use
`composer require google/recaptcha "~1.1"` or add the following to your
`composer.json`:
```json
"require": {
"google/recaptcha": "~1.1"
}
### Composer (Recommended)

[Composer](https://getcomposer.org/) is a widely used dependency manager for PHP
packages. This reCAPTCHA client is available on Packagist as
[`google/recaptcha`](https://packagist.org/packages/google/recaptcha) and can be
installed either by running the `composer require` command or adding the library
to your `composer.json`. To enable Composer for you project, refer to the
project's [Getting Started](https://getcomposer.org/doc/00-intro.md)
documentation.

To add this dependency using the command, run the following from within your
project directory:
```
composer require google/recaptcha "~1.1"
```

### Manual installation
Alternatively, add the dependency directly to your `composer.json` file:
```json
"require": {
"google/recaptcha": "~1.1"
}
```

If you wish to install the library manually (i.e. without Composer),
an autoloader is provided as `src/autoload.php`. You can require it in
your script instead of the usual `vendor/autoload.php` created by
Composer. For example,
### Direct download (no Composer)

If you wish to install the library manually (i.e. without Composer), then you
can use the links on the main project page to either clone the repo or download
the ZIP file. For convenience, an autoloader script is provided in
`src/autoload.php` which you can require into your script instead of Composer's
`vendor/autoload.php`. For example:
```php
require('/path/to/recaptcha/autoload.php');

$recaptcha = new \ReCaptcha\ReCaptcha($secret);
// etc.
```

The classes in the project are structured according to the
[PSR-4](http://www.php-fig.org/psr/psr-4/) standard, so you may of course also
use your own autoloader or require the needed files directly in your code.

### Development install

If you would like to contribute to this project or run the unit tests on within
your own environment you will need to install the development dependencies, in
this case that means [PHPUnit](https://phpunit.de/). If you clone the repo and
run `composer install` from within the repo, this will also grab PHPUnit and all
its dependencies for you. If you only need the autoloader installed, then you
can always specify to Composer not to run in development mode, e.g. `composer
install --no-dev`.

*Note:* These dependencies are only required for development, there's no
requirement for them to be included in your production code.

## Usage

First, register keys for your site at https://www.google.com/recaptcha/admin
Expand All @@ -57,21 +87,23 @@ if ($resp->isSuccess()) {
}
```

You can see an end-to-end working example in [examples/example-captcha.php](examples/example-captcha.php)
You can see an end-to-end working example in
[examples/example-captcha.php](examples/example-captcha.php)

## Upgrading

### From 1.0.0

The previous version of this client is still available on the `1.0.0` tag
[in this repo](https://github.com/google/recaptcha/tree/1.0.0) but it is purely
for reference and will not receive any updates.
The previous version of this client is still available on the `1.0.0` tag [in
this repo](https://github.com/google/recaptcha/tree/1.0.0) but it is purely for
reference and will not receive any updates.

The major changes in 1.1.0 are:
* installation now via Composer;
* class loading also via Composer;
* classes now namespaced;
* old method call was `$rc->verifyResponse($remoteIp, $response)`, new call is `$rc->verify($response, $remoteIp)`
* installation now via Composer;
* class loading also via Composer;
* classes now namespaced;
* old method call was `$rc->verifyResponse($remoteIp, $response)`, new call is
`$rc->verify($response, $remoteIp)`

## Contributing

Expand Down

0 comments on commit afdcb02

Please sign in to comment.