https://github.com/huluti/altcha-bundle
A Symfony bundle to help integrate ALTCHA with Symfony forms.
https://github.com/huluti/altcha-bundle
altcha captcha symfony symfony-bundle
Last synced: 6 months ago
JSON representation
A Symfony bundle to help integrate ALTCHA with Symfony forms.
- Host: GitHub
- URL: https://github.com/huluti/altcha-bundle
- Owner: Huluti
- License: mit
- Created: 2024-11-24T09:13:47.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-20T14:49:21.000Z (7 months ago)
- Last Synced: 2025-04-09T19:09:43.247Z (6 months ago)
- Topics: altcha, captcha, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 109 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
A simple package to help integrate ALTCHA on Symfony Form.
======================

This packages integrates [ALTCHA](https://altcha.org/), a privacy-friendly Captcha alternative, with Symfony forms.
Simply add an `AltchaType` field to your form and this package will automatically check the challenge issue.> ALTCHA uses a proof-of-work mechanism to protect your website, APIs, and online services from spam and unwanted content.
>
>Unlike other solutions, ALTCHA is free, open-source and self-hosted, does not use cookies nor fingerprinting, does not track users, and is fully compliant with GDPR.
>
> Say goodbye to tedious puzzle-solving and improve your website's UX by integrating a fully automated proof-of-work mechanism.## Support
- Symfony 6.4+
- PHP 8.1+## Installation
You can install the package via Composer:
```bash
composer require huluti/altcha-bundle
```Add bundle into config/bundles.php file :
```php
Huluti\AltchaBundle\HulutiAltchaBundle::class => ['all' => true]
```Add a config file `config/packages/huluti_altcha.php`:
```php
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,
'use_stimulus' => false,
'hide_logo' => false,
'hide_footer' => false
]);if ('test' === $containerConfigurator->env()) {
// Disable captcha in test environment
$containerConfigurator->extension('huluti_altcha', [
'enable' => false,
]);
}
};
```Import bundle routes:
```php
$routingConfigurator->import('@HulutiAltchaBundle/config/routes.yml');
```### Use with your Symfony Form
Create a form type and insert an AltchaType to add the captcha:
```php
add('name', TextType::class, ['label' => false, 'attr' => ['placeholder' => 'name']])
->add('message', TextareaType::class, ['label' => false, 'attr' => ['placeholder' => 'message']])
->add('security', AltchaType::class, [
'label' => false,
"floating" => true,
"hide_logo" => false,
"hide_footer" => false,
])
->add('submit', SubmitType::class)
;
}public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Contact::class,
]);
}
}
```### Use inside UX Live component
Asset mapper is required to use this package in the UX Live component.
```composer require symfony/asset-mapper```
```php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('huluti_altcha', [
'enable' => true,
'hmacKey' => 'RANDOM_SECRET_KEY',
'floating' => false,
'use_stimulus' => true
]);
};
```## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.