openwide / zend-captcha-bundle
Zend Captcha 扩展包
v1.0.0
2016-10-11 08:21 UTC
Requires
- php: >=5.3.9
- symfony/framework-bundle: ~2.3|~3.0
- zendframework/zend-captcha: ^2.5
- zendframework/zend-session: ^2.5
- zendframework/zend-text: ^2.5
- zendframework/zend-validator: ^2.5
This package is auto-updated.
Last update: 2024-09-11 19:22:13 UTC
README
ZendCaptchaBundle 为 Symfony 表单组件添加了对验证码表单类型的支持。与 Symfony 的兼容性
如果你使用 SYmfony >= 2.8 安装
步骤 1: 下载 ZendCaptchaBundle
使用 Composer
composer require openwide/zend-captcha-bundle
或者在 composer.json 中添加 bundle
// ...
"require": {
// ...
"openwide/zend-captcha-bundle": "dev-master"
// ...
},
// ...
步骤 2: 启用扩展包
<?php // app/appKernel.php public function registerBundles() { $bundles = array( // ... new Openwide\Bundle\ZendCaptchaBundle\OpenwideZendCaptchaBundle(), ); }
用法
你可以这样在你的表单中使用 "zend captcha" 类型
<?php use Openwide\Bundle\ZendCaptchaBundle\Form\Type\ZendCaptchaType; // ... $builder // ... ->add('captcha', ZendCaptchaType::class)
选项
- img_dir 允许你指定存储 CAPTCHA 图片的目录。默认是 /web/captcha
- font 允许你指定你将使用的字体。默认是 arial.ttf
- img_url 允许你指定用于 HTML 标记的 CAPTCHA 图片的相对路径。默认是 “/captcha”。
- suffix 允许你指定 CAPTCHA 图片的文件名后缀。默认是 “.png”。
- width 允许你指定生成的 CAPTCHA 图片的像素宽度。默认是 200px。
- height 允许你指定生成的 CAPTCHA 图片的像素高度。默认是 50px。
- font_size 允许你指定生成 CAPTCHA 的字体大小(像素)。默认是 24px。
- dot_noise_level 和 line_noise_level 允许你控制图像中将包含多少“噪声”,形式为随机点和线条。默认是 100 个点和 5 条线。噪声在图像扭曲变换前后各添加一次。
- word_len 允许你指定生成的“单词”的字符长度。默认是 8。
- expiration 允许你指定 CAPTCHA 图像在文件系统中的最大生存时间。每次调用 CAPTCHA 对象时都会定期运行垃圾回收,删除所有已过期的图像。过期值应以秒为单位指定。默认是 600。
- gc_freq 允许你指定垃圾回收应该运行的频率。垃圾回收将在每 1/gcFreq 次调用时运行。默认是 100。
- bypass_code 始终验证 CAPTCHA 的代码(默认=null)