Download the PHP package s1syphos/php-simple-captcha without Composer

On this page you can find all versions of the php package s1syphos/php-simple-captcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-simple-captcha

php-simple-captcha

Build

php-simple-captcha creates & verifies captcha images, dependency-free & respecting your user's privacy. It's a fork of Gregwar/Captcha, but supports modern PHP versions and comes with several new features & bug fixes.

Installation

It's available for Composer:

Getting started

Upon invoking the main class, you may specify a phrase (the string hidden in the captcha image), otherwise one will be created randomly:

If you want the generated phrase to be even more random, buildPhrase() has your back:

From here, you can ..

(1) .. save the captcha to a file:

(2) .. output it directly in the browser:

(3) .. inline its data URI in your HTML:

You'll be able to get the code and compare it with a user input:

Note: Since one of the randomly selected fonts may contain letters looking very similar, you should validate user input using compare(), otherwise you might end up with unsolvable captchas:

Usage

From there, the following functions are available:

randomCharacter(string $charset = null): string

Picks random character (using given charset)

buildPhrase(int $length = 5, string $charset = null): string

Builds random phrase (of given length using given charset)

build(int $width = 150, int $height = 40): self

Builds captcha image

buildAgainstOCR(int $width = 150, int $height = 40): self

Builds captcha image until it is (supposedly) unreadable by OCR software

save(string $filename, int $quality = 90): void

Saves captcha image to file

output(int $quality = 90, string $type = 'jpg'): void

Outputs captcha image directly

fetch(int $quality = 90, string $type = 'jpg'): string

Fetches captcha image contents

inline(int $quality = 90, string $type = 'jpg'): string

Fetches captcha image as data URI

compare(string $phrase, string $string = null): bool

Checks whether captcha was solved correctly. Upon passing another string, both strings are compared (instead of first string & current phrase).

Configuration

There are several settings you may use in order to change the behavior of the library:

$builder->phrase (string)

Captcha phrase. Default: random, see buildPhrase()

$builder->fonts (array)

Paths to captcha fonts. Default: Font files inside fonts

$builder->distort (bool)

Whether to distort the image. Default: true

$builder->interpolate (bool)

Whether to interpolate the image. Default: true

$builder->maxLinesBehind (int)

Maximum number of lines behind the captcha phrase. Default: random

$builder->maxLinesFront (int)

Maximum number of lines in front of the captcha phrase. Default: random

$builder->maxAngle (int)

Maximum character angle. Default: 8

$builder->maxOffset (int)

Maximum character offset. Default: 5

$builder->bgColor (array|string)

Background color, either RGB values (array), HEX value or 'transparent' (string). Default: random

$builder->lineColor (array|string)

Line color RGB values (array) or HEX value (string)

$builder->textColor (array|string)

Text color RGB values (array) or HEX value (string)

$builder->bgImage (string)

Path to background image. Default: background fill, see bgColor

$builder->applyEffects (bool)

Whether to apply any effects. Default: true

$builder->applyNoise (bool)

Whether to apply background noise (using random letters). Default: true

$builder->noiseFactor (int)

Multiples of phrase length to be used for noise generation. Default: 2

$builder->applyPostEffects (bool)

Whether to apply post effects. Default: true

$builder->applyScatterEffect (bool)

Whether to enable scatter effect. Default: true

$builder->randomizeFonts (bool)

Whether to use random font for each symbol. Default: true

Examples

Have a look at the examples inside the demo folder, which should give you an impression of what's possible - or simply whip up a PHP development server:

Fonts

The fonts directory includes:

Credits

This library is based on Gregwar/Captcha, introducing several new features & bug fixes.


All versions of php-simple-captcha with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-gd Version *
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package s1syphos/php-simple-captcha contains the following files

Loading the files please wait ....