Captcha Plugin for CakePHP
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.
composer require dereuromark/cakephp-captcha
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
Using the default MathEngine we can simply attach the behavior to the Table class.
Load the helper, e.g in your AppView:
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:
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.