sfCaptchaGDPlugin - 1.0.1

The sfCaptchaGDPlugin is a symfony plugin that provides captcha functionality based on GD library.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source | Show as Markdown

sfCaptchaGD plugin

The sfCaptchaGDPlugin is a symfony plugin that provides captcha functionality based on GD library.

It gives you the lib with Captcha class and the module to secure your symfony forms in a minute with a good captcha.

Installation

Install the plugin

    symfony plugin-install http://plugins.symfony-project.com/sfCaptchaGDPlugin

Enable one or more modules in your settings.yml * sfCaptchaGD

    all:
      .settings:
        enabled_modules:      [sfCaptchaGD](default,)

Clear you cache

    symfony cc

Secure your form

To secure a symfony form:

Put the following lines inside of your form

    hasError('captcha')) echo form_error('captcha') ?>
    get('captcha')) ?><br>
    <img src='<?php echo url_for('/captcha').'?'.time(); ?>'>

Put the following code into your form's validator yml file:

        fields:
          captcha:
            required:
              msg:            Enter characters from image
            sfCaptchaGDValidator:
              captcha_error:  Entered characters are wrong, try again

Configuration options

These options are default for captcha, you can change any of them, putting in settings.yml

all:
    sf_captchagd:
        image_width:                100 # image width in pixels
        image_height:               30 # image height in pixels
        chars:                      "123456789" # possible chars in captcha
        length:                     4 # length of captcha
        font_size:                  18 # font size

        # possible chars colors
        font_color:                 ["8b8787", "550707", "3526E6", "88531E"]("252525",)

        # chars fonts
        fonts:                      ["brushcut/BRUSHCUT.TTF", "molten/molten.ttf", "planet_benson/Planetbe.ttf", "whoobub/WHOOBUB_.TTF"]("akbar/akbar.ttf",) 
        background_color:           DDDDDD # image background color
        border_color:               000000 # image border color

TODO