Download the PHP package florentingarnier/sylius-spam-protection-plugin without Composer

On this page you can find all versions of the php package florentingarnier/sylius-spam-protection-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-spam-protection-plugin

Sylius Spam Protection Plugin

CI Latest Version Total Downloads Sylius

Protects the public forms of your Sylius shop against spam bots, without reCAPTCHA and without any puzzle for your customers. It relies on florentingarnier/spam-protection-bundle: a honeypot, single-use timed tokens, a proof of work solved by the browser, per-form rate limiting, IP reputation and gibberish detection.

Sylius form Scope Free text checked
Contact (ContactType) contact message
Registration (CustomerRegistrationType) registration —
Password reset request (UserRequestPasswordResetType) password_reset —

Requirements

Sylius 1.14 requires api-platform/core 2.7, whose releases are all affected by security advisories. Composer 2.9 and later refuses to install them unless your project ignores these advisories, as this plugin does for its own CI in composer.json (config.policy.advisories.ignore-id). This concerns Sylius itself, not the plugin, which does not use API Platform.

Sylius 2

The registration form of Sylius 2 is a Live Component, which submits the form every time it re-renders it, to validate the fields. These re-renders save nothing, so the plugin does not verify them: otherwise they would consume the token and count as rejected attempts. Live actions are still verified, as they may save the form.

Installation

  1. Require the plugin:

  2. If you do not use Symfony Flex, enable the bundle and the plugin:

  3. Load the JavaScript solver in your shop theme, as explained in the bundle documentation. Without it, the protected forms cannot be submitted.

  4. Download the IP reputation lists, then schedule the command daily:

Configuration is optional: see the bundle documentation.

How the fields are rendered

The Sylius shop templates end their forms with render_rest: false, so a field added to a form is not rendered automatically. The plugin renders the protection with a priority of -100 in the forms' template events on Sylius 1:

and in the forms' Twig hooks on Sylius 2:

The Sylius shop does not render the errors of these forms, so the plugin also renders its rejection message at the top of each form, with a priority of 1000 (block florentin_garnier_spam_protection_error). If your theme renders the errors of a form itself ({{ form_errors(form) }}), remove this block from its event or hook, as shown below, so that the message appears once.

If your theme overrides these templates:

To remove a block from an event or a hook, for example when your theme renders the field elsewhere (florentin_garnier_spam_protection) or the errors of the form (florentin_garnier_spam_protection_error):

Protecting other forms

Any Symfony form can be protected with the bundle's form type, including your own shop forms:

Testing

The integration tests render the shop forms with the Sylius Test Application. They need no database.

Without restriction, Composer may mix Symfony versions (Behat does not support Symfony 8 yet, for instance). Choose the Sylius and Symfony versions to test, among the combinations listed in the requirements; Symfony Flex applies SYMFONY_REQUIRE to every Symfony package:

Behat supports neither Symfony 5.4 nor Symfony 8: to test them, remove it first, as the CI does (see ci.yml).

Behat

The Behat scenarios submit the shop forms like a visitor: from Chrome, which solves the proof of work, and without JavaScript, like a bot. They run on Sylius 2 and need MySQL, Chrome and the Symfony CLI.

With another database URL, set DATABASE_URL in tests/TestApplication/.env.test.local. Failed steps leave a screenshot and the page in etc/build/, and the verdicts of the protection are logged to var/log/spam_protection.log.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md and the Code of Conduct. Report security issues privately, as described in SECURITY.md.

License

Released under the MIT License.


All versions of sylius-spam-protection-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
florentingarnier/spam-protection-bundle Version ^0.2.2
sylius/sylius Version ^1.14 || ^2.0
symfony/config Version ^5.4.21 || ^6.4 || ^7.4 || ^8.0
symfony/dependency-injection Version ^5.4.21 || ^6.4 || ^7.4 || ^8.0
symfony/form Version ^5.4.21 || ^6.4 || ^7.4 || ^8.0
symfony/http-foundation Version ^5.4.21 || ^6.4 || ^7.4 || ^8.0
symfony/http-kernel Version ^5.4.21 || ^6.4 || ^7.4 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package florentingarnier/sylius-spam-protection-plugin contains the following files

Loading the files please wait ...