Dead simple, unobstrusive and extendable captcha solution for CakePHP
Clone or download
Latest commit 9807daf Jan 6, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Increase image size. Sep 21, 2017
docs Update README.md May 30, 2018
src Remove deprecations. Dec 12, 2018
tests CaePHP 3.7 Dec 2, 2018
vendor restore files. Mar 29, 2017
.editorconfig Add phpstan support. Sep 21, 2017
.gitattributes Fix tests Oct 21, 2017
.gitignore ignore Mar 27, 2017
.travis.yml Update plugin travis. Jan 6, 2019
LICENSE Init composer.json Jun 8, 2016
README.md Switch to https. Jan 6, 2019
composer.json Switch to https. Jan 6, 2019
phpunit.xml.dist CakePHP 3.6 compatibility. Apr 20, 2018

README.md

Captcha Plugin for CakePHP

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.