<?php
use Laminas\Captcha\Figlet;
$captcha = new Figlet(['wordLen' => 3]);
// generates captcha token and stores it in Session
$captcha->generate();
$captchaStr = $captcha->getFiglet()
->render($captcha->getWord());
echo '<pre>' . $captchaStr . '</pre>';
// two possible user inputs.
// id = generated session id
// input = user input
$wrongInput = [
'id' => 1,
'input' => 'asdf',
];
$rightInput = [
'id' => $captcha->getId(),
'input' => $captcha->getWord(),
];
// validate user input
dump($captcha->isValid($wrongInput));
dump($captcha->isValid($rightInput));
_____ __ __ _ __ / ____|| \ \\/ // | |/ // / //---`' \ ` // | ' // \ \\___ | || | . \\ \_____|| |_|| |_|\_\\ `----` `-`' `-` --`
^ false
^ true