Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fetzi/kirby-uniform-recaptcha

Extension of the kirby-uniform plugin
https://github.com/fetzi/kirby-uniform-recaptcha

kirby kirby-plugin php recaptcha

Last synced: about 1 month ago
JSON representation

Extension of the kirby-uniform plugin

Awesome Lists containing this project

README

        

# kirby-uniform-recaptcha

An extension to the Kirby 2 plugin [Uniform](https://github.com/mzur/kirby-uniform) (v3) to add the Google reCAPTCHA guard.

## Installation

### Kirby CLI

Get the [Kirby CLI](https://github.com/getkirby/cli) and run `kirby plugin:install fetzi/kirby-uniform-recaptcha`.

### Traditional

[Download](https://github.com/fetzi/kirby-uniform-recaptcha/archive/master.zip) the repository and extract it to `site/plugins/uniform-recaptcha`.

### Composer

Run `composer require fetzi/kirby-uniform-recaptcha`. Then add the second `require` to the `index.php` like this:

```php
// load kirby
require(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php');
require 'vendor'.DS.'autoload.php';
```

Be sure to include the new `vendor` directory in your deployment.

## Configuration

Define the mandatory config settings:

1. `c::set('uniform-recaptcha-sitekey', 'YOUR RECAPTCHA SITEKEY');`
2. `c::set('uniform-recaptcha-secret', 'YOUR RECAPTCHA SECRET');`

## Usage

You can use the `recaptchaGuard` in your controllers form definition:

```php
$form = new Form(/* ... */);

if (r::is('POST')) {
$form->recaptchaGuard()
->emailAction(/* ... */);
}
```

To embed the recaptcha field into your template simply call
``

The plugin needs the recaptcha Javascript File provided by Google. You can either include the [JavaScript file](https://www.google.com/recaptcha/api.js) directly into your page or by calling the method `embed_recaptcha_js()` in your template.

**Example**
```html+php

Name
error('name')): ?> class="erroneous" name="name" type="text" value="old('name') ?>">



```

## Author

Johannes Pichler [https://johannespichler.com](https://johannespichler.com)