Skip to content

Commit 64b06ec

Browse files
committed
added readme
1 parent 681dc3b commit 64b06ec

File tree

1 file changed

+113
-17
lines changed

1 file changed

+113
-17
lines changed

README.md

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,141 @@
22

33
[![Latest Version on Packagist][ico-version]][link-packagist]
44
[![Total Downloads][ico-downloads]][link-downloads]
5-
[![Build Status][ico-travis]][link-travis]
6-
[![StyleCI][ico-styleci]][link-styleci]
75

8-
This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.
6+
7+
## Features
8+
9+
- Score Comparision
10+
- Support multiple input field for different <form> tag
11+
- Support custom implementation on config interface
12+
- Support custom implementation on request method interface
13+
14+
## Requirement
15+
16+
This package requires the following dependencies:
17+
18+
- Laravel 5.x
19+
20+
- php > 5
21+
22+
- Please ensure that you have read basic information from Google reCAPTCHA v3.
923

1024
## Installation
1125

26+
1227
Via Composer
1328

1429
``` bash
1530
$ composer require ryandeng/googlerecaptcha
1631
```
1732

18-
## Usage
33+
If your Laravel framework version <= 5.4, please register the service provider in your config file: /config/app.php, otherwise please go to step 3.
34+
35+
```sh
36+
Ryandadeng\Securepayframe\SecurePayFrameServiceProvider::class
37+
```
38+
39+
If your Laravel framework version is >= 5.5, just run the following command to publish views and config.
40+
```sh
41+
php artisan vendor:publish --provider="RyanDeng\GoogleReCaptcha\GoogleReCaptchaServiceProvider"
42+
```
1943

20-
## Change log
44+
After installation, you should see a googlerecaptcha/googlerecaptcha.blade file in your views folder and googlerecaptchav3.php in your app/config folder.
2145

22-
Please see the [changelog](changelog.md) for more information on what has changed recently.
46+
If you want to change the default template, please check Advanced Usage.
2347

24-
## Testing
2548

26-
``` bash
27-
$ composer test
49+
## Basic Usage
50+
#### Setting up your Google reCAPTCHA details
51+
52+
Please register all details on host_name, site_key, secret_key and site_verify_url.
53+
54+
Specify your Score threshold in score_setting, e.g.
55+
56+
[
57+
'action' => 'contact_us', // Google reCAPTCHA required paramater
58+
'id' => 'contactus_id', // your HTML input field id
59+
'threshold' => 0.2, // score threshold
60+
'is_enabled' => false // if this is true, the system will do score comparsion against your threshold for the action
61+
]
62+
63+
Note: if you want to enable Score Comparision, you also need to enable is_score_enabled to be true.
64+
65+
Remember to turn on the service by enable is_service_enabled to be true.
66+
67+
For more details please check comments in config file.
68+
69+
#### Validation Class
70+
71+
You can use provided Validation object to verify your reCAPTCHA.
72+
73+
``` php
74+
use RyanDeng\GoogleReCaptcha\Validations\GoogleReCaptchaValidationRule
75+
$rule = [
76+
'g-recaptcha-response' => [new GoogleReCaptchaValidationRule('action_name',$ip)]
77+
];
78+
```
79+
80+
'g-recaptcha-response' is the name of your <input> field, which is currently hard-coded.
81+
82+
GoogleReCaptchaValidationRule($actionName, $ip) which accepts two optional parameters:
83+
- $actionName: if its NULL, the package won't verify action with google response.
84+
85+
- $ip: request remote ip, this is Google reCAPTCHA parameter.
86+
87+
88+
#### Facade Class
89+
90+
$action: Google reCAPTCHA definition
91+
92+
$response: which is a value comes from g-recaptcha-response
93+
94+
$ip: optional
95+
96+
GoogleReCaptcha::setAction($action)->verifyResponse($response, $ip);
97+
98+
## Advanced Usage
99+
100+
#### Custom implementation on Config
101+
102+
For some users, they might store the config details in their own storage e.g database. You can create your own class and implement:
103+
104+
```
105+
RyanDeng\GoogleReCaptcha\Interfaces\ReCaptchaConfigInterface
106+
```
107+
108+
Remember to register your implementation, e.g.
109+
110+
``` php
111+
$this->app->bind(
112+
ReCaptchaConfigInterface::class,
113+
YourOwnCustomImplementation::class
114+
);
115+
```
116+
117+
#### Custom implementation on Request method
118+
119+
The package uses Curl to verify, if you want to use your own request method, You can create your own class and implement
120+
```
121+
RyanDeng\GoogleReCaptcha\Interfaces\RequestClientInterface
28122
```
29123

30-
## Contributing
124+
Remember to register your implementation.
125+
``` php
126+
$this->app->bind(
127+
RequestClientInterface::class,
128+
YourOwnCustomImplementation::class
129+
);
130+
```
131+
## Testing
132+
133+
This test file will be added in the next release.
31134

32-
Please see [contributing.md](contributing.md) for details and a todolist.
33135

34136
## Security
35137

36138
If you discover any security related issues, please email ryandadeng@gmail.com instead of using the issue tracker.
37139

38-
## Credits
39-
40-
- [Ryan Deng][link-author]
41-
- [All Contributors][link-contributors]
42140

43141
## License
44142

@@ -51,6 +149,4 @@ MIT. Please see the [license file](license.md) for more information.
51149

52150
[link-packagist]: https://packagist.org/packages/ryandeng/googlerecaptcha
53151
[link-downloads]: https://packagist.org/packages/ryandeng/googlerecaptcha
54-
[link-travis]: https://travis-ci.org/ryandeng/googlerecaptcha
55-
[link-styleci]: https://styleci.io/repos/12345678
56152
[link-author]: https://github.com/ryandadeng

0 commit comments

Comments
 (0)