monsieurbiz/sylius-anti-spam-plugin

This plugins adds captcha and allows you to manage your spams.

Installs: 8 661

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 7

Forks: 3

Open Issues: 0

Type:sylius-plugin

v2.0.0 2025-05-21 12:22 UTC

This package is auto-updated.

Last update: 2025-05-21 12:22:28 UTC


README

Banner of Sylius Anti Spam plugin

Anti Spam

Anti Spam Plugin license Tests Status Recipe Status Security Status

This plugins adds captcha and allows you to manage your spams.

Compatibility

Sylius Version PHP Version
2.0 8.2 - 8.3

ℹ️ For Sylius 1.x, see our 1.x branch and all 1.x releases.

Installation

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-plugin
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:migrate

Generate the migration and update your database schema with the new customer entity field:

bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate

Documentation

Use reCAPTCHA for register and contact form

Create 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

Remove automatically quarantine entities (experimental)

  1. Add the monsieurbiz_anti_spam.quarantineable tag on our entity, for example for Customer:
    App\Entity\Customer\Customer:
        tags: ['monsieurbiz_anti_spam.quarantineable']
  1. 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'
  1. 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-items

Contributing

You can open an Issue or a Pull Request if you want! 😘
Thank you!

Sponsors

This plugin is sponsored by:

License

This plugin is completely free and released under the MIT License.