cleantalk/yii2-antispam
Composer 安装命令:
composer require cleantalk/yii2-antispam
包简介
Anti-spam yii2 extension by CleanTalk with protection against spam bots and manual spam
关键字:
README 文档
README
Spam Bot Protection for Yii2 Forms — reCAPTCHA Alternative.
Anti-spam extension for the Yii2 framework powered by the CleanTalk API.
Invisible protection from spam bots on contact, comment, and registration forms — no reCAPTCHA, no puzzles, no delays.
Features
- Works invisibly in the background (no user interaction required)
- Blocks spam bots using CleanTalk’s multi-layered checks
- reCAPTCHA-free UX — no puzzles, images, or questions
- Easy integration into Yii2 forms and models
- Supports contact forms, comment forms, and registration forms
If you find this project useful, please consider starring ⭐ it on GitHub — it helps us grow and support development!
Websites that trust CleanTalk!
Requirements
- Yii 2.0 or above
- CleanTalk account https://cleantalk.org/register?product=anti-spam
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
-
Get access key on https://cleantalk.org/register?platform=yii2
-
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',
],
...
],
- 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'*/]
];
}
}
- 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
cleantalk/yii2-antispam 适用场景与选型建议
cleantalk/yii2-antispam 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.52k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「antispam」 「yii2」 「cleantalk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cleantalk/yii2-antispam 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cleantalk/yii2-antispam 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cleantalk/yii2-antispam 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Honeypot extension for Nette Forms
A custom URL rule class for Yii 2 which allows to create translated URL rules
Increase your Flarum forum's security with hCaptcha.
Stand-alone antispambot function from WordPress
PHP client for tirreno security analytics API
Animated captcha generator
统计信息
- 总下载量: 18.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2015-06-30