Download the PHP package mobicms/captcha without Composer
On this page you can find all versions of the php package mobicms/captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package captcha
mobicms/captcha
This library is a simple PHP CAPTCHA. Prevent form spam by generating random Captcha images.
Major features:
- lightweight and fast
- not create any temporary files
- there are many settings that allow you to change the look of the picture
- you can use your own font sets
Example:
Installation
The preferred method of installation is via Composer. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
Simply usage (v.5)
-
Display in form:
- Check whether the entered code is correct:
Customization (v.5)
You can change CAPTCHA settings through \Mobicms\Captcha\Image
class properties.
Image properties
Image: resizing
int $imageWidth = 190, int $imageHeight = 90
Keep in mind that the width of the image will affect the density of the text.
If the characters are very creeping on top of each other and become illegible,
then increase the width of the image, reduce the length of the verification code, or the font size.
Image: default font size
int $defaultFontSize = 30
This setting affects the size of all fonts used.
Image: fonts mixer
bool $fontMix = true
If this parameter is set to TRUE
(default), a random font will be used for each character in the image.
If you set it to FALSE
, then a single, randomly selected font will be used for all characters in the image.
Image: fonts folders
array $fontFolders
You can use your own set of TTF fonts. To do this, specify one or more folders in the array where .ttf font files are located.
Keep in mind that this package already has some fonts. If you plan to use them, then merge the arrays.
Image: adjust font
array $fontsTune
Some fonts may have a size that looks too small or large compared to others.
In this case, you need to specify an adjustment relative to the default size.
Also, if necessary, you can force the specified font to use only uppercase or lowercase characters.
Adjustment parameters are passed to the $fontsTune
class property as an array.
Keep in mind that the class already has some adjustments, so if you use fonts from this package,
then combine your array of adjustments with an array of $fontsTune
properties.
Verification code properties
Verification code: length
int $lengthMin = 4
, int $lengthMax = 5
The length of the generated code string will be randomly between the
specified minimum and maximum values.
Verification code: character Set
string $characterSet = '23456789ABCDEGHJKMNPQRSTUVXYZabcdeghjkmnpqrstuvxyz'
In this string you can specify a set of characters that will be used randomly
when generating the verification code. Avoid using characters that can be interpreted
ambiguously, such as O (letter) and 0 (number).
Verification code: excluded сombinations
string $excludedCombinationsPattern = 'rn|rm|mm|ww'
You can use a pattern to specify combinations of adjacent characters that should not appear next to each other.
For example, rn can be interpreted as m, and so on...
Verification code: use your own
The Image class already has the ability to generate validation code,
which will be sufficient in most use cases.
However, if necessary, you can generate the validation code yourself
and then pass string to the constructor when the Image
class is initialized:
Contributing
Contributions are welcome! Please read Contributing for details.
In our development, we follow the principles of YAGNI and KISS. The source code should not have extra unnecessary functionality and should be as simple and efficient as possible.
License
This package is licensed for use under the MIT License (MIT).
Please see LICENSE for more information.
Our links
- mobiCMS Project website and support forum
- GitHub mobiCMS project repositories
All versions of captcha with dependencies
ext-gd Version *