PHPackages                             pelock/yii2-anti-spam-form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pelock/yii2-anti-spam-form

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

pelock/yii2-anti-spam-form
==========================

Anti-Spam Form is a form replacement component for the Yii2 Framework for creating anti-spam forms that are invisible in HTML code to spam bots &amp; harvesting tools.

1.0.0(3y ago)172↓100%[1 issues](https://github.com/PELock/yii2-anti-spam-form/issues)Apache-2.0PHPPHP &gt;=5.4.0

Since Jul 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/PELock/yii2-anti-spam-form)[ Packagist](https://packagist.org/packages/pelock/yii2-anti-spam-form)[ RSS](/packages/pelock-yii2-anti-spam-form/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Anti-Spam Form for Yii2 Framework
=================================

[](#anti-spam-form-for-yii2-framework)

**Anti-Spam Form** is a form replacement component for the [Yii2 Framework](https://www.yiiframework.com) for creating anti-spam forms that are invisible in HTML code to spam bots &amp; harvesting tools.

What's the idea behind anti-spam forms?
---------------------------------------

[](#whats-the-idea-behind-anti-spam-forms)

The concept is simple. Spam bots in most cases are simple tools. They will read your website, look for `` HTML tags and artificially fill up the form fields and post it.

The usual spam bot is a web scraper written in Python retrieving raw HTML webpage content **without** evaluating JS code.

But one thing **missed** in anti-spam detection methods is that spam bots usually cannot process JavaScript code. For a good reason. It's time-consuming and requires JS interpreter to evaluate the JS code within the web page. And it's not that easy to incorporate JS evaluation without using complex &amp; slower execution engines usually based on Chromium etc.

How to break spam bots?
-----------------------

[](#how-to-break-spam-bots)

Simple - put the HTML forms wrapped within JS code. Not the entire form, but the starting `` tag with all its properties.

Suddenly the spam bots are unable to find it. Less spam without too much work.

How to install Anti-Spam Form component?
----------------------------------------

[](#how-to-install-anti-spam-form-component)

Install it first. Preferred way of WebApi interface installation is via [composer](https://getcomposer.org/).

Run:

```
php composer.phar require --prefer-dist pelock/yii2-anti-spam-form "*"

```

Or add this entry:

```
"pelock/yii2-anti-spam-form": "*"

```

directly to your `composer.json` in require section.

Installation package is available at

How to use Anti-Spam Form?
--------------------------

[](#how-to-use-anti-spam-form)

Replace your regular Yii2 `ActiveForm` component:

```
