Skip to content

Commit 0f47939

Browse files
committed
Update docs
1 parent ac378ba commit 0f47939

File tree

6 files changed

+32
-115
lines changed

6 files changed

+32
-115
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ about: Report an issue with the PHP client library
1313
* OS name and version:
1414
* PHP version:
1515
* Web server name and version:
16-
* `google/recaptcha` version:
16+
* `phpfui/recaptcha` version:
1717
* Browser name and version:
1818

1919
**Reproducing the issue**
2020
<!-- Where possible link to a URL where the problem can be seen or show code that causes it -->
2121

2222
* URL (optional): <!-- if your integration is already deployed and the issue is visible -->
2323
* Code (optional): <!-- share a link to the code you're using or an example in a Gist -->
24-
24+
2525
***User steps***
2626
<!-- Detail the necessary steps to reproduce the issue. Include the output of any error messages. -->
27-
27+
2828
1. Visit page...

ARCHITECTURE.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ secret key, specify any additional validation rules, and then call `verify()`
55
with the reCAPTCHA response and user's IP address. For example:
66

77
```php
8-
<?php
98
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
109
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
1110
->verify($gRecaptchaResponse, $remoteIp);
@@ -31,14 +30,12 @@ For example, if you want to use [cURL](https://secure.php.net/curl) instead you
3130
can do this:
3231

3332
```php
34-
<?php
3533
$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\CurlPost());
3634
```
3735

3836
Alternatively, you can also use a [socket](https://secure.php.net/fsockopen):
3937

4038
```php
41-
<?php
4239
$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
4340
```
4441

CONTRIBUTING.md

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,19 @@
11
# Contributing
22

3-
Want to contribute? Great! First, read this page (including the small print at
4-
the end).
5-
6-
## Contributor License Agreement
7-
8-
Before we can use your code, you must sign the [Google Individual Contributor
9-
License
10-
Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
11-
(CLA), which you can do online. The CLA is necessary mainly because you own the
12-
copyright to your changes, even after your contribution becomes part of our
13-
codebase, so we need your permission to use and distribute your code. We also
14-
need to be sure of various other things—for instance that you'll tell us if you
15-
know that your code infringes on other people's patents. You don't have to sign
16-
the CLA until after you've submitted your code for review (a link will be
17-
automatically added to your Pull Request) and a member has approved it, but you
18-
must do it before we can put your code into our codebase. Before you start
19-
working on a larger contribution, you should get in touch with us first through
20-
the issue tracker with your idea so that we can help out and possibly guide you.
21-
Coordinating up front makes it much easier to avoid frustration later on.
3+
Want to contribute? Great! First, read this page.
224

235
## Linting and testing
246

25-
We use PHP Coding Standards Fixer to maintain coding standards and PHPUnit to
26-
run our tests. For convenience, there are Composer scripts to run each of these:
7+
We use PHP Coding Standards Fixer to maintain coding standards and PHPUnit to run our tests. For convenience, there are Composer scripts to run each of these:
278

289
```sh
2910
composer run-script lint
11+
composer run-script lint-fix
3012
composer run-script test
3113
```
3214

33-
These are run automatically by [Travis
34-
CI](https://travis-ci.org/google/recaptcha) against your Pull Request, but it's
35-
a good idea to run them locally before submission to avoid getting things
36-
bounced back. That said, tests can be a little daunting so feel free to submit
37-
your PR and ask for help.
15+
These are run automatically by [GitHub Actions](https://github.com/phpfui/recaptcha/actions) against your Pull Request, but it's a good idea to run them locally before submission to avoid getting things bounced back. That said, tests can be a little daunting so feel free to submit your PR and ask for help.
3816

3917
## Code reviews
4018

41-
All submissions, including submissions by project members, require review.
42-
Reviews are conducted on the Pull Requests. The reviews are there to ensure and
43-
improve code quality, so treat them like a discussion and opportunity to learn.
44-
Don't get disheartened if your Pull Request isn't just automatically approved.
45-
46-
### The small print
47-
48-
Contributions made by corporations are covered by a different agreement than the
49-
one above, the Software Grant and Corporate Contributor License Agreement.
19+
All submissions, including submissions by project members, require review. Reviews are conducted on the Pull Requests. The reviews are there to ensure and improve code quality, so treat them like a discussion and opportunity to learn. Don't get disheartened if your Pull Request isn't just automatically approved.

README.md

Lines changed: 22 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,39 @@
1-
# reCAPTCHA PHP client library
1+
# Google's reCAPTCHA PHP client library
22

3-
[![Build Status](https://travis-ci.org/google/recaptcha.svg)](https://travis-ci.org/google/recaptcha)
4-
[![Coverage Status](https://coveralls.io/repos/github/google/recaptcha/badge.svg)](https://coveralls.io/github/google/recaptcha)
5-
[![Latest Stable Version](https://poser.pugx.org/google/recaptcha/v/stable.svg)](https://packagist.org/packages/google/recaptcha)
6-
[![Total Downloads](https://poser.pugx.org/google/recaptcha/downloads.svg)](https://packagist.org/packages/google/recaptcha)
3+
[![Build Status](https://github.com/phpfui/recaptcha/actions/workflows/tests.yml/badge.svg)](https://github.com/phpfui/recaptcha/actions?query=workflow%3Atests)
4+
[![Coverage Status](https://coveralls.io/repos/github/google/recaptcha/badge.svg)](https://coveralls.io/github/phpfui/recaptcha)
5+
[![Latest Stable Version](https://img.shields.io/packagist/v/phpfui/recaptcha.svg)](https://packagist.org/packages/phpfui/recaptcha)
6+
![](https://img.shields.io/badge/PHPStan-level%206-brightgreen.svg?style=flat)
77

8-
reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse.
9-
This is a PHP library that wraps up the server-side verification step required
10-
to process responses from the reCAPTCHA service. This client supports both v2
11-
and v3.
8+
reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse. This is a PHP library that wraps up the server-side verification step required to process responses from the reCAPTCHA service. This client supports both V2 and V3.
129

1310
- reCAPTCHA: https://www.google.com/recaptcha
14-
- This repo: https://github.com/google/recaptcha
11+
- This repo: https://github.com/phpfui/recaptcha
1512
- Hosted demo: https://recaptcha-demo.appspot.com/
16-
- Version: 1.3.0
13+
- Version: 2.0
1714
- License: BSD, see [LICENSE](LICENSE)
1815

19-
## Installation
16+
### Notice: This is not an officially supported version of the Google Recaptcha package
2017

21-
### Composer (recommended)
18+
It appears that Google is no longer interested in supporting their PHP Open Source packages for newer versions of PHP (8.4 and up). This package is an updated version of the original Google package. It has been updated to GitHub Actions and modern PHP standards. Every effort has been made to not change logic or behavior other than conformating to modern PHP standards.
2219

23-
Use [Composer](https://getcomposer.org) to install this library from Packagist:
24-
[`google/recaptcha`](https://packagist.org/packages/google/recaptcha)
25-
26-
Run the following command from your project directory to add the dependency:
27-
28-
```sh
29-
composer require google/recaptcha "^1.3"
30-
```
31-
32-
Alternatively, add the dependency directly to your `composer.json` file:
33-
34-
```json
35-
"require": {
36-
"google/recaptcha": "^1.3"
37-
}
38-
```
20+
This package will be retired if Google decides to support modern PHP versions.
3921

4022
### Support for earlier versions of PHP
4123

42-
The 1.3 release moves to PHP 8 and up. For earlier versions, you will need to
43-
stay with the 1.2 releases.
44-
45-
### Direct download
46-
47-
Download the [ZIP file](https://github.com/google/recaptcha/archive/master.zip)
48-
and extract into your project. An autoloader script is provided in
49-
`src/autoload.php` which you can require into your script. For example:
50-
51-
```php
52-
require_once '/path/to/recaptcha/src/autoload.php';
53-
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
54-
```
24+
The 2.0 release allows for PHP 8.4. If you need only PHP 8.3 support and lower, you should continue to use the google/recaptcha package. For versions of PHP before 8.0, you will need to stay with the official Google 1.2 release on packagist (google/recaptcha).
5525

56-
The classes in the project are structured according to the
57-
[PSR-4](https://www.php-fig.org/psr/psr-4/) standard, so you can also use your
58-
own autoloader or require the needed files directly in your code.
26+
The classes in the project are structured according to the [PSR-4](https://www.php-fig.org/psr/psr-4/) standard, so you can also use your own autoloader or require the needed files directly in your code.
5927

6028
## Usage
6129

62-
First obtain the appropriate keys for the type of reCAPTCHA you wish to
63-
integrate for v2 at https://www.google.com/recaptcha/admin or v3 at
64-
https://g.co/recaptcha/v3.
30+
First obtain the appropriate keys for the type of reCAPTCHA you wish to integrate for v2 at https://www.google.com/recaptcha/admin or v3 at https://g.co/recaptcha/v3.
6531

66-
Then follow the [integration guide on the developer
67-
site](https://developers.google.com/recaptcha/intro) to add the reCAPTCHA
68-
functionality into your frontend.
32+
Then follow the [integration guide on the developer site](https://developers.google.com/recaptcha/intro) to add the reCAPTCHA functionality into your frontend.
6933

70-
This library comes in when you need to verify the user's response. On the PHP
71-
side you need the response from the reCAPTCHA service and secret key from your
72-
credentials. Instantiate the `ReCaptcha` class with your secret key, specify any
73-
additional validation rules, and then call `verify()` with the reCAPTCHA
74-
response (usually in `$_POST['g-recaptcha-response']` or the response from
75-
`grecaptcha.execute()` in JS which is in `$gRecaptchaResponse` in the example)
76-
and user's IP address. For example:
34+
This library comes in when you need to verify the user's response. On the PHP side you need the response from the reCAPTCHA service and secret key from your credentials. Instantiate the `ReCaptcha` class with your secret key, specify any additional validation rules, and then call `verify()` with the reCAPTCHA response (usually in `$_POST['g-recaptcha-response']` or the response from `grecaptcha.execute()` in JS which is in `$gRecaptchaResponse` in the example) and user's IP address. For example:
7735

7836
```php
79-
<?php
8037
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
8138
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
8239
->verify($gRecaptchaResponse, $remoteIp);
@@ -101,11 +58,9 @@ The following methods are available:
10158
- `setChallengeTimeout($timeoutSeconds)`: set a timeout between the user passing
10259
the reCAPTCHA and your server processing it.
10360

104-
Each of the `set`\*`()` methods return the `ReCaptcha` instance so you can chain
105-
them together. For example:
61+
Each of the `set`\*`()` methods return the `ReCaptcha` instance so you can chain them together. For example:
10662

10763
```php
108-
<?php
10964
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
11065
$resp = $recaptcha->setExpectedHostname('recaptcha-demo.appspot.com')
11166
->setExpectedAction('homepage')
@@ -119,29 +74,22 @@ if ($resp->isSuccess()) {
11974
}
12075
```
12176

122-
You can find the constants for the libraries error codes in the `ReCaptcha`
123-
class constants, e.g. `ReCaptcha::E_HOSTNAME_MISMATCH`
77+
You can find the constants for the libraries error codes in the `ReCaptcha` class constants, e.g. `ReCaptcha::E_HOSTNAME_MISMATCH`
12478

12579
For more details on usage and structure, see [ARCHITECTURE](ARCHITECTURE.md).
12680

12781
### Examples
12882

129-
You can see examples of each reCAPTCHA type in [examples/](examples/). You can
130-
run the examples locally by using the Composer script:
83+
You can see examples of each reCAPTCHA type in [examples/](examples/). You can run the examples locally by using the Composer script:
13184

13285
```sh
13386
composer run-script serve-examples
13487
```
13588

136-
This makes use of the in-built PHP dev server to host the examples at
137-
http://localhost:8080/
89+
This makes use of the in-built PHP dev server to host the examples at http://localhost:8080/
13890

139-
These are also hosted on Google AppEngine Flexible environment at
140-
https://recaptcha-demo.appspot.com/. This is configured by
141-
[`app.yaml`](./app.yaml) which you can also use to [deploy to your own AppEngine
142-
project](https://cloud.google.com/appengine/docs/flexible/php/download).
91+
These are also hosted on Google AppEngine Flexible environment at https://recaptcha-demo.appspot.com/. This is configured by [`app.yaml`](./app.yaml) which you can also use to [deploy to your own AppEngine project](https://cloud.google.com/appengine/docs/flexible/php/download).
14392

14493
## Contributing
14594

146-
No one ever has enough engineers, so we're very happy to accept contributions
147-
via Pull Requests. For details, see [CONTRIBUTING](CONTRIBUTING.md)
95+
No one ever has enough engineers, so we're very happy to accept contributions via Pull Requests. Please run PHPCSFixer and PHPStan on all PRs.

examples/appengine-https.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* BSD 3-Clause License
45
* @copyright (c) 2019, Google Inc.

examples/recaptcha-v3-verify.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* BSD 3-Clause License
45
* @copyright (c) 2019, Google Inc.

0 commit comments

Comments
 (0)