Skip to content

Commit

Permalink
prepare release v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Oct 12, 2023
1 parent e333ca5 commit fcbe95e
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ $ php spark config:publish

# Usage

Since `v2.1.0`, environment config can be use for multiple config with `.env`

```env
recaptcha.recaptchaSiteKey
recaptcha.recaptchaSecretKey
recaptcha.recaptchaLang
```

## Initialization

```php
Expand Down Expand Up @@ -65,6 +73,64 @@ class Example
}
```

Since `v2.0.0`, you can using helper

```php
<?php

namespace App\Controllers;

class Home extends BaseController
{
public function index(): string
{
helper('recaptcha');

$data = [
'scriptTag' => getScriptTag(),
'widgetTag' => getWidget(),
];

$captcha = $this->request->getPost('g-recaptcha-response');
$response = verifyResponse($captcha);

if (isset($response['success']) and $response['success'] === true) {
echo "You got it!";
}

return view('welcome_message', $data);
}
}
```
or directly use `service`
```php
<?php

namespace App\Controllers;

class Home extends BaseController
{
public function index(): string
{
$recaptcha = service('recaptcha');

$data = [
'scriptTag' => $recaptcha->getScriptTag(),
'widgetTag' => $recaptcha->getWidget(),
];

$captcha = $this->request->getPost('g-recaptcha-response');
$response = $recaptcha->verifyResponse($captcha);

if (isset($response['success']) and $response['success'] === true) {
echo "You got it!";
}

return view('welcome_message', $data);
}
}
```

## Render reCAPTCHA Widget

- Default
Expand Down

0 comments on commit fcbe95e

Please sign in to comment.