1. Go to this page and download the library: Download arodu/utilcake library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
arodu / utilcake example snippets
public function bootstrap(){
parent::bootstrap();
$this->addPlugin('UtilCake');
}
public function initialize(): void{
parent::initialize();
$this->loadComponent('UtilCake.ReCaptcha', [
'public_key'=>'RECAPTCHA_PUBLIC_KEY',
'secret_key'=>'RECAPTCHA_SECRET_KEY',
]);
}
// any action
public function action(){
// ...
if ($this->request->is('post')) {
if($this->ReCaptcha->verify($this->request->getData())){
// when the verification is successful
// ...
}else{
// when the verification is not successful
$this->Flash->error(__('reCaptcha failed, try again'));
}
}
// ...
}