PHP code example of huluti / altcha-bundle
1. Go to this page and download the library: Download huluti/altcha-bundle 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/ */
huluti / altcha-bundle example snippets
Huluti\AltchaBundle\HulutiAltchaBundle::class => ['all' => true]
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('huluti_altcha', [
'enable' => true,
'hmacKey' => 'RANDOM_SECRET_KEY',
'floating' => true,
]);
if ('test' === $containerConfigurator->env()) {
// Disable captcha in test environment
$containerConfigurator->extension('huluti_altcha', [
'enable' => false,
]);
}
};
$routingConfigurator->import('@HulutiAltchaBundle/config/routes.yml');
namespace App\Form;
use App\Entity\Contact;
use Huluti\AltchaBundle\Type\AltchaType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, ['label' => false, 'attr' => ['placeholder' => 'name']])
->add('message', TextareaType::class, ['label' => false, 'attr' => ['placeholder' => 'message']])
->add('security', AltchaType::class, ['label' => false])
->add('submit', SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Contact::class,
]);
}
}