arodu/util-cake

This package is abandoned and no longer maintained. The author suggests using the arodu/utilcake package instead.

CakePHP Plugin, collection of utilities for cakephp 3.x

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

v0.0.5 2020-03-22 16:22 UTC

This package is auto-updated.

Last update: 2020-07-05 22:15:25 UTC


README

CakePHP Plugin, collection of utilities for CakePHP 3.x

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require arodu/util-cake

Configuration

You can load the plugin using the shell command:

bin/cake plugin load UtilCake

Or you can manually add the loading statement in the src/Application.php file of your application:

public function bootstrap(){
    parent::bootstrap();
    $this->addPlugin('UtilCake');
}

Prior to 3.6.0

Plugin::load('UtilCake');

How to use

Permit

Under construction

reCaptcha V3

In the controller file

public function initialize(){
  parent::initialize();
  $this->loadComponent('UtilCake.reCaptcha', [
    'public_key' => 'RECAPTCHA_PUBLIC_KEY',
    'secret_key' => 'RECAPTCHA_SECRET_KEY',
  ]);
}

public function action(){
  // ...
  if ($this->request->is('post')) {
    if($this->reCaptcha->verify($this->request)){
      // when the verification is successful
    }else{
      // when the verification is not successful
      $this->Flash->error(__('reCaptcha failed, try again'));
    }
  }
  // ...
}

In the template Template/ControllerName/action.ctp

echo $this->Form->create();
echo $this->element('UtilCake.reCaptcha/input');
echo $this->Form->end();

echo $this->element('UtilCake.reCaptcha/script', ['action'=>'IdName']);