blackknight467/ayah-bundle

此包已被废弃,不再维护。没有建议的替代包。

这是一个用于 Symfony 2 的人机验证包。此包添加了 'ayah' 表单类型。简单易用。让我们告别验证码。

安装: 246

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

v2.0 2016-01-22 10:10 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:25:03 UTC


README

AYAHBundle 为 Symfony2 表单组件添加了对 "ayah" 表单类型的支持。

最低要求:Symfony 2.7

注意:我与 "Are you a human" 没有任何关联。我只是一个需要在使用 Symfony 2 表单实现 "Are You A Human" 并决定分享他的代码以使那些想要告别验证码的人的生活更轻松的人。

安装

步骤 1:下载 AYAHBundle

使用 Composer

将以下内容添加到你的 composer.json 文件的 "require" 部分

    "blackknight467/ayah-bundle": "2.*"

步骤 2:启用包

最后,在内核中启用该包

<?php
// app/appKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new blackknight467\AYAHBundle\AYAHBundle(),
    );
}

配置

将以下配置添加到你的 app/config/config.yml

ayah:
    publisher_key: 'your ayah publisher key here'
    scoring_key: 'your ayah scoring key here'

高级配置

失败的人机测试的默认错误信息为

'您未通过 "Are You A Human" 测试。这是一个问题。研究一下并再试一次。

要自定义错误信息,请将以下内容添加到你的 app/config/config.yml

ayah:
    error_message: 'your error message here'

使用

<?php
    // ...
    $builder->add('ayah', 'ayah'); // That's all !
    // ...

高级使用

如果你需要出于某种原因(例如自动测试)跳过测试评分,请使用 assume_human 选项。

如果 assume_human 为 true,它将关闭 "Are You A Human" 字段的形式验证,因此如果跳过测试则不会出现错误。

示例

<?php
    // ...
    $builder->add('ayah', 'ayah', array(
                'assume_human' => true
            ))

    // ...

许可协议

此包在 MIT 许可协议下。请参阅包中的完整许可协议:LICENSE