This plugins adds captcha and allows you to manage your spams.
| Sylius Version | PHP Version |
|---|---|
| 2.0, 2.1 | 8.2 - 8.3 |
ℹ️ For Sylius 1.x, see our 1.x branch and all 1.x releases.
If you want to use our recipes, you can configure your composer.json by running:
composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'composer require monsieurbiz/sylius-anti-spam-pluginRun post installation command
cp -r vendor/monsieurbiz/sylius-anti-spam-plugin/dist/config config/For the installation without flex, follow these additional steps
Change your config/bundles.php file to add the line for the plugin :
<?php
return [
//..
MonsieurBiz\SyliusRichEditorPlugin\MonsieurBizSyliusAntiSpamPlugin::class => ['all' => true],
];Then create the config file in config/packages/monsieurbiz_sylius_anti_spam_plugin.yaml :
imports:
- { resource: "@MonsieurBizSyliusAntiSpamPlugin/Resources/config/config.yaml" }
services:
# Add the "monsieurbiz_anti_spam.quarantineable" tag on the quarantineable entity (not autoconfigure the entity…)
App\Entity\Customer\Customer:
tags: ['monsieurbiz_anti_spam.quarantineable']Finally import the routes in config/routes/monsieurbiz_sylius_anti_spam_plugin.yaml :
monsieurbiz_sylius_anti_spam_admin:
resource: "@MonsieurBizSyliusAntiSpamPlugin/Resources/config/routes/admin.yaml"
prefix: /%sylius_admin.path_name%Update customer entity
Your Customer entity should implement MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareInterface and use the MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareTrait trait.
namespace App\Entity\Customer;
use Doctrine\ORM\Mapping as ORM;
+ use MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareInterface;
+ use MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareTrait;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_customer')]
- class Customer extends BaseCustomer
+ class Customer extends BaseCustomer implements QuarantineItemAwareInterface
{
+ use QuarantineItemAwareTrait
}Update your database schema
Update your database schema with the plugin migrations:
bin/console doctrine:migrations:migrateGenerate the migration and update your database schema with the new customer entity field:
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrateCreate or get your reCAPTCHA key and secret here.
Add your site key and secret to your .env file:
RECAPTCHA3_KEY=my_site_key
RECAPTCHA3_SECRET=my_secret- Add the
monsieurbiz_anti_spam.quarantineabletag on our entity, for example for Customer:
App\Entity\Customer\Customer:
tags: ['monsieurbiz_anti_spam.quarantineable']- Confirm or adjust the exceeded periods, by quarantine level, before remove the entities. By default, the:
- suspected item is removed after 1 year
- likely item is removed after 182 days
- proven item is removed after 90 days
You can change there periods in config/packages/monsieurbiz_sylius_anti_spam_plugin.yaml:
monsieurbiz_sylius_anti_spam:
exceeded:
suspected: '1 day'
- Add in your crontab the remove command, example:
0 */6 * * * /usr/bin/flock -n /tmp/lock.app.remove_exceeded_quarantine bin/console monsieurbiz:anti-spam:remove-exceeded-quarantine-itemsYou can open an Issue or a Pull Request if you want! 😘
Thank you!
This plugin is sponsored by:
This plugin is completely free and released under the MIT License.
