Download the PHP package gregwar/captcha without Composer
On this page you can find all versions of the php package gregwar/captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gregwar/captcha
More information about gregwar/captcha
Files in gregwar/captcha
Package captcha
Short Description Captcha generator
License MIT
Homepage https://github.com/Gregwar/Captcha
Rated 4.00 based on 4 reviews
Informations about the package captcha
Captcha
Installation
With composer :
Usage
You can create a captcha with the CaptchaBuilder
:
You can then save it to a file :
Or output it directly :
Or inline it directly in the HTML page:
You'll be able to get the code and compare it with a user input :
You can compare the phrase with user input:
API
You can use these functions :
- __construct($phrase = null), constructs the builder with the given phrase, if the phrase is null, a random one will be generated
- getPhrase(), allow you to get the phrase contents
- setDistortion($distortion), enable or disable the distortion, call it before
build()
- isOCRReadable(), returns
true
if the OCR can be read using theocrad
software, you'll need to have shell_exec enabled, imagemagick and ocrad installed - buildAgainstOCR($width = 150, $height = 40, $font = null), builds a code until it is not readable by
ocrad
- build($width = 150, $height = 40, $font = null), builds a code with the given $width, $height and $font. By default, a random font will be used from the library
- save($filename, $quality = 80), saves the captcha in the $filename, with the given quality
- get($quality = 80), returns the image data
- output($quality = 80), directly outputs the image
- inline($quality = 80), returns the jpeg code directly in the HTML page
- setBackgroundColor($r, $g, $b), sets the background color to force it (this will disable many effects and is not recommended)
- setBackgroundAlpha($alpha), sets the background transparency 0 is fully opaque, 127 is fully transparent
- setBackgroundImages(array($imagepath1, $imagePath2)), Sets custom background images to be used as captcha background. It is recommended to disable image effects when passing custom images for background (ignore_all_effects). A random image is selected from the list passed, the full paths to the image files must be passed.
- setInterpolation($interpolate), enable or disable the interpolation (enabled by default), disabling it will be quicker but the images will look uglier
- setIgnoreAllEffects($ignoreAllEffects), disable all effects on the captcha image. Recommended to use when passing custom background images for the captcha.
- testPhrase($phrase), returns true if the given phrase is good
- setMaxBehindLines($lines), sets the maximum number of lines behind the code
- setMaxFrontLines($lines), sets the maximum number of lines on the front of the code
- setImageType($type), sets the image output type to "jpeg", "png" or "gif"
- setScatterEffect($bool), enable or disable scatter effect (fuzzyness)
If you want to change the number of character, you can call the phrase builder directly using extra parameters:
You can also pass directly the wanted phrase to the builder:
Complete example
If you want to see an example you can have a look at the demo/form.php
, which uses demo/session.php
to
render a captcha and check it after the submission
Symfony Bundle
You can have a look at the following repository to enjoy the Symfony 2 bundle packaging this captcha generator : https://github.com/Gregwar/CaptchaBundle
Yii2 Extension
You can use the following extension for integrating with Yii2 Framework : https://github.com/juliardi/yii2-captcha
License
This library is under MIT license, have a look to the LICENSE
file
All versions of captcha with dependencies
ext-gd Version *
ext-mbstring Version *
ext-fileinfo Version *
symfony/finder Version *