https://github.com/cradlephp/cradle-captcha
Google captcha helpers for CradlePHP
https://github.com/cradlephp/cradle-captcha
captcha cradle cradlephp v1 v2
Last synced: 11 days ago
JSON representation
Google captcha helpers for CradlePHP
- Host: GitHub
- URL: https://github.com/cradlephp/cradle-captcha
- Owner: CradlePHP
- License: mit
- Created: 2018-03-12T03:51:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-20T10:42:43.000Z (almost 6 years ago)
- Last Synced: 2025-07-06T20:05:56.803Z (11 months ago)
- Topics: captcha, cradle, cradlephp, v1, v2
- Language: PHP
- Homepage: http://cradlephp.github.io
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cradle-captcha
Google Captcha Helpers
## Install
```
composer require cradlephp/cradle-captcha
```
Then in `/bootstrap.php`, add
```
->register('cradlephp/cradle-captcha')
```
## Setup
Go to [https://www.google.com/recaptcha/](https://www.google.com/recaptcha/) and
register for a token and secret.
Open `/config/services.php` and add
```
'captcha-main' => array(
'token' => '',
'secret' => ''
),
```
## Usage
In any of your routes add the following code.
```
cradle()->trigger('captcha-load', $request, $response);
```
The CSRF token will be found in `$request->getStage('captcha')`. In your form
template, be sure to add this key in a hidden field like the following.
```
```
When validating this form in a route you can use the following
```
cradle()->trigger('captcha-validate', $request, $response);
```
If there is an error, it will be found in the response error object message.
You can check this using the following.
```
if($response->isError()) {
$message = $response->getMessage();
//report the error
}
```