CakePHP Captcha Plugin


CakePHP 3
CakePHP 1&2


CakePHP 3
CakePHP 1&2


Arvind Kumar
@Inimist Technologies

Need Help?

Get in touch
Call +919876831310

Demo: Math Challenge for Cakephp 3

This is a simple Math Challenge plugin for CakePHP 3. Simple plug and play support to your cakephp forms to make them secure by adding cakephp match captcha support. Follow simple instructions to install cakephp Math Challenge plugin using composer and configure a few settings in your view files of your cakephp application.

CakePHP Captcha Plugin by Inimist Technologies is one of the most used, stable and trusted CakePHP captcha plugin support since 2009. We have maintained CakePHP Captcha support throughout these long years and we are still committed to maintain it as long we found it useful for the large community of CakePHP framework.

Cakephp Math Challenge - Simple Math Demo

1 * 1 = ?

{Source Code: CakePHP Captcha, Math Challenge}

(Code with yellow background in the source code below indicates the only changes to your application)

Call Captcha behavior in the model ie Table class UsersTable.php in this example

public function initialize(array $config)
	$this->addBehavior('Captcha.Captcha', ['field'=>'captcha_input_field_name']);

Place in form, in view file register.ctp in this example

<?= $this->Form->create($user, ['novalidate']) ?>
		<legend><?= __('CakePHP Image Captcha Demo') ?></legend>
		echo $this->Form->input('name');
		echo $this->Captcha->create('captcha_input_field_name', [
	<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>

Call Captcha component in the initialize function of the conroller, UsersControllerr.php in this example

public function initialize()

Place in UsersControllerr.php action, "register" here

public function register()
	$user = $this->Users->newEntity();
	if ($this->request->is('post')) {
		$this->Users->setCaptcha('captcha_input_field_name', $this->Captcha->getCode('captcha_input_field_name'));
		$user = $this->Users->newEntity($this->request->getData());
		if ($user->errors()) {
			$this->Flash->error(__('Validation failed.'));
		}	else	{
			$this->Flash->success(__('Validation success.'));

That should be it!

If you should have any proble, question, comment, feedback or any suggestion for CakePHP Captcha Plugin please feel free to drop us a message at one of our contact us page or at Github