https://github.com/area17/twill-google-recaptcha
https://github.com/area17/twill-google-recaptcha
Last synced: about 13 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/area17/twill-google-recaptcha
- Owner: area17
- License: apache-2.0
- Created: 2022-11-16T15:49:26.000Z (over 2 years ago)
- Default Branch: 1.x
- Last Pushed: 2024-04-16T14:34:27.000Z (about 1 year ago)
- Last Synced: 2025-04-12T15:59:02.148Z (2 months ago)
- Language: PHP
- Size: 85 KB
- Stars: 1
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Google reCAPTCHA v3 Twill Capsule
## Installing
## Supported Versions
Composer will manage this automatically for you, but these are the supported versions between Twill and this package.| Twill Version | HTTP Basic Auth Capsule |
|---------------|-------------------------|
| 3.x | 2.x |
| 2.x | 1.x |### Require the Composer package:
```bash
composer require area17/twill-google-recaptcha
```### Publish the configuration
```bash
php artisan vendor:publish --provider="A17\TwillGoogleRecaptcha\ServiceProvider"
```#### Create debugging routes to check if it's all good
```php
Route::prefix('/debug')->group(function () {
Route::get('/google-recaptcha-3', [A17\TwillGoogleRecaptcha\Http\Controllers\TwillGoogleRecaptchaFrontController::class, 'show'])->name(
'google-recaptcha.show',
);Route::post('/google-recaptcha-3', [A17\TwillGoogleRecaptcha\Http\Controllers\TwillGoogleRecaptchaFrontController::class, 'store'])->name(
'google-recaptcha.store',
);
});
```#### Translate validation messages on validation.php
```php
'google_recaptcha' => 'Failed invisible Google reCAPTCHA, please try again.',
```#### Sharing it in your views
To have a `$twillGoogleRecaptcha` shared on your views, you can call this helper on your `AppServiceProvider`:
```php
\A17\TwillGoogleRecaptcha\Services\Helpers::viewShare()
```One possible example is to use `View::composer()` to load the needed variables into your views:
``` php
TWILL_GOOGLE_RECAPTCHA_PRIVATE_KEY=
TWILL_GOOGLE_RECAPTCHA_ENABLED=true
```#### Check the working form example
File: app/Twill/Capsules/GoogleRecaptchas/resources/views/front/form.blade.php
#### Use the validator
```php
use A17\TwillGoogleRecaptcha\Support\Validator as GoogleRecaptchaValidator;$request->validate([
'g-recaptcha-response' => ['required', 'string', new GoogleRecaptchaValidator()],
]);
```## Contribute
Please contribute to this project by submitting pull requests.