cleantalk/yii2-antispam Anti-spam yii2 extension by CleanTalk with protection against spam bots and manual spam

cleantalkantispam

Anti-spam extension by CleanTalk for Yii2 framework.

No Captcha, no questions, no counting animals, no puzzles, no math.

Build Status

Requirements

Yii 2.0 or above

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist cleantalk/yii2-antispam

or add

"cleantalk/yii2-antispam": "~1.0.0"

to the require section of your composer.json.

Usage

1) Get access key on https://cleantalk.org/register?platform=yii2

2) Open your application configuration in protected/config/web.php and modify components section:

// application components
'components'=>[
    ...
        'antispam' => [
            'class' => 'cleantalk\antispam\Component',
            'apiKey' => 'Your API KEY',
        ],
    ...
],

3) Add validator in your model, for example ContactForm:

namespace app\models;

use cleantalk\antispam\validators\MessageValidator;
use Yii;
use yii\base\Model;

/**
 * ContactForm is the model behind the contact form.
 */
class ContactForm extends Model
{
    public $name;
    public $email;
    public $body;
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // name, email, subject and body are required
            [['name', 'email', 'subject', 'body'], 'required'],
            // email has to be a valid email address
            ['email', 'email'],
            ['body', MessageValidator::className(), 'emailAttribute'=>'email', /*'nickNameAttribute'=>'name'*/]
        ];
    }
}

4) In form view add widget for hidden Javascript checks:

<?php $form = ActiveForm::begin(); ?>
    ...
    <?= \cleantalk\antispam\Widget::widget()?>
    ...
    <?= Html::submitButton('Submit')?>
    ...
<?php ActiveForm::end(); ?>

User registration validator

See cleantalk\antispam\validators\UserValidator

Example rules:

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'email'], 'required'],
            ['email', 'email'],
            ['email', UserValidator::className(), 'nickNameAttribute'=>'name']
        ];
    }

License

GNU General Public License

Resources

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v1.0.0 is the latest of one release



GPL-3.0 license
Stats
2 github stars & 2 github forks
2 downloads in the last day
173 downloads in the last 30 days
4029 total downloads