dereuromark/cakephp-captcha

A CakePHP plugin to integrate captchas.

Installs: 2 612

Dependents: 1

Suggesters: 0

Stars: 2

Watchers: 1

Forks: 1

Open Issues: 3

Type:cakephp-plugin

0.1.2 2019-01-06 12:47 UTC

README

Build Status Coverage Status Minimum PHP Version License Total Downloads Coding Standards

Allows any type of image-based captchas for your forms.

A CakePHP 3.x plugin to

  • Easily integrate captchas in your CakePHP application.

This plugin requires CakePHP 3.7+.

Whats in this plugin

  • Simple match captchas that will already do the trick without annoying "I can't read those letters".
  • Extendable interface approach to easily hook in your own engine.

Whats the gotchas

  • Dead simple, no fancy JS or alike.
  • Cross-tab safe (not session based as in overwriting each other per request).
  • Completely stand-alone plugin, no third party stuff involved/needed.

Demo

See https://sandbox.dereuromark.de/sandbox/captchas

Setup

composer require dereuromark/cakephp-captcha

and

bin/cake plugin load Captcha -b -r

You also need to import the SQL schema. The quickest way is using Migrations plugin:

bin/cake migrations migrate -p Captcha

Basic Usage

Using the default MathEngine we can simply attach the behavior to the Table class.

Load the helper, e.g in your AppView:

$this->loadHelper('Captcha.Captcha');

Add a captcha control in your form:

echo $this->Captcha->render(['placeholder' => __('Please solve the riddle')]);

Add the behavior at runtime in your controller action:

$this->Ads->addBehavior('Captcha.Captcha');

Saving a new ad would now require a valid captcha solution.

// This would come from the form POST
$postData = [
	'title' => 'Looking for a friend'
];
$ad = $this->Ads->newEntity($postData);
$success = $this->Users->save($user);

For detailed documentation see Docs.