1. Go to this page and download the library: Download willybahuaud/gaitcha 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/ */
willybahuaud / gaitcha example snippets
use Gaitcha\Config;
use Gaitcha\AbstractEndpoint;
$config = new Config([
'secret' => 'your-secret-key-at-least-32-characters',
]);
class CaptchaEndpoint extends AbstractEndpoint
{
protected function sendJsonResponse(array $data): void
{
header('Content-Type: application/json');
echo json_encode($data);
}
public function handle(): void
{
$this->sendJsonResponse($this->handleInit());
}
}
$endpoint = new CaptchaEndpoint($config);
$endpoint->handle();
use Gaitcha\Config;
use Gaitcha\ValidationOrchestrator;
$config = new Config(['secret' => 'your-secret-key-at-least-32-characters']);
$orchestrator = new ValidationOrchestrator($config);
$result = $orchestrator->validate($_POST);
if ($result->isAccepted()) {
// Process the form.
} else {
// $result->getReason():
// token_absent | token_invalid | token_expired
// token_already_used | score_insufficient | log_malformed
}
use Gaitcha\Config;
use Gaitcha\FileTokenStore;
$config = new Config([
'secret' => 'your-secret-key-at-least-32-characters',
'anti_replay' => true,
'token_store' => new FileTokenStore('/tmp/gaitcha-tokens.json'),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.