PHPackages                             onnov/captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. onnov/captcha

ActiveLibrary

onnov/captcha
=============

Captcha generator with the most flexible settings.

v1.0.1(6y ago)07MITPHPPHP &gt;=5.6.0CI failing

Since Aug 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/onnov/captcha)[ Packagist](https://packagist.org/packages/onnov/captcha)[ Docs](https://github.com/onnov/captcha)[ RSS](/packages/onnov-captcha/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/adaac29b28aab7ae901605857694384b020a5e41d01a31c5f5cd27f67b338535/68747470733a2f2f7472617669732d63692e6f72672f6f6e6e6f762f636170746368612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/onnov/captcha)[![Latest Stable Version](https://camo.githubusercontent.com/b82e1e92e0e4cf71e27b6bb8202db164980754f1eeb5e06ed7a96df5835808c7/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6e6f762f636170746368612f762f737461626c65)](https://packagist.org/packages/onnov/captcha)[![License](https://camo.githubusercontent.com/630c44cc9e9fb5022c11f582f6978954d01f4bfad3e2167027e0d3315f36d1f7/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6e6f762f636170746368612f6c6963656e7365)](https://packagist.org/packages/onnov/captcha)

captcha
=======

[](#captcha)

[![Captchas examples](https://camo.githubusercontent.com/cb876247dbe9db0819662792a35b8adeb88de1ea31976f2f55553e2a4b70c099/68747470733a2f2f666f726d6d2e72752f636170746368612f636170746368612e706e67)](https://camo.githubusercontent.com/cb876247dbe9db0819662792a35b8adeb88de1ea31976f2f55553e2a4b70c099/68747470733a2f2f666f726d6d2e72752f636170746368612f636170746368612e706e67)

[Captcha demo](https://formm.ru/captcha)

Captcha with the most flexible settings. Are changing:

- Font
- The size
- Colors
- Effects

Installation
------------

[](#installation)

[Composer](https://getcomposer.org) (recommended) Use Composer to install this library from Packagist: onnov/captcha

Run the following command from your project directory to add the dependency:

```
composer require onnov/captcha

```

Alternatively, add the dependency directly to your composer.json file:

```
"require": {
    "onnov/captcha": "^1.0"
}

```

The classes in the project are structured according to the PSR-4 standard, so you can also use your own autoloader or require the needed files directly in your code.

Usage
-----

[](#usage)

### SYMFONY

[](#symfony)

If you use SYMFONY framework:

in services.yaml file

```
services:
    Onnov\Captcha\Captcha:
        autowire: true
```

in the controller or service

```
use Onnov\Captcha\Captcha;
```

```
    /** @var Captcha */
    protected $captcha;

    public function __construct(Captcha $captcha) {
        $this->captcha = $captcha;
    }
```

### Without framework

[](#without-framework)

```
use Onnov\Captcha\Captcha;

$captcha = new Captcha();
```

#### Get captcha with default settings:

[](#get-captcha-with-default-settings)

```
/**
 * Returns CaptchaReturn Object
 *
 * @var CaptchaReturn $result
 */
$result = $captcha->getCaptcha();

// Save the value of the captcha in the session
$_SESSION['CaptchaKeyString'] = $result->getKeyString();

// Send the desired headers
foreach ($result->getHeaders() as $k => $v) {
    header($k.': '.$v);
}

// Send captcha to browser
echo $result->getImg();
```

Custom setting
--------------

[](#custom-setting)

The default font is ActionJackson. You can use monsterShadow or baveuse3d fonts already inside.

```
use Onnov\Captcha\Font\MonsterShadowFont;
use Onnov\Captcha\CaptchaConfig;

$captchaConfig = (new CaptchaConfig())->setFonts([new MonsterShadowFont()]);
$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

You can use several fonts at the same time, they will be used in random order.

```
use Onnov\Captcha\Font\ActionJacksonFont;
use Onnov\Captcha\Font\MonsterShadowFont;
use Onnov\Captcha\Font\Baveuse3dFont;
use Onnov\Captcha\CaptchaConfig;

$captchaConfig = (new CaptchaConfig())
            ->setFonts(
                [
                    new ActionJacksonFont(),
                    new MonsterShadowFont(),
                    new Baveuse3dFont(),
                ]
            );
$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

You can use any TTF font, specifying the path and the proportions to it in the form of two width and height parameters (you will have to select the parameters experimentally)

```
use Onnov\Captcha\Font\ModelFont;
use Onnov\Captcha\CaptchaConfig;

$font = (new ModelFont())
            ->setFontPath(__DIR__.'/SignboardCpsNr.ttf')
            ->setCharWidth(25)
            ->setCharHeight(30);
$captchaConfig = (new CaptchaConfig())->setFonts([$font]);
$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

### Distortion effects

[](#distortion-effects)

By default, two effects are used to distort the image in captcha:

- Interference
- Wave distortion (The algorithm is taken from the site )

You can turn off both effects.

```
use Onnov\Captcha\CaptchaConfig;

$captchaConfig = (new CaptchaConfig())->setEffects([]);
$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

You can use only one effect.

```
use Onnov\Captcha\CaptchaConfig;
use Onnov\Captcha\Effect\WaveDistortionEffect;

$captchaConfig = (new CaptchaConfig())->setEffects([new WaveDistortionEffect()]);
$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

You can change the sequence of application (by default, first Interference then WaveDistortion)

```
use Onnov\Captcha\CaptchaConfig;
use Onnov\Captcha\Effect\WaveDistortionEffect;
use Onnov\Captcha\Effect\InterferenceEffect;

$captchaConfig = (new CaptchaConfig())
            ->setEffects(
                [
                    new WaveDistortionEffect(),
                    new InterferenceEffect(),
                ]
            );
$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

Each effect can be configured.

```
use Onnov\Captcha\CaptchaConfig;
use Onnov\Captcha\Effect\InterferenceConfig;
use Onnov\Captcha\Effect\InterferenceEffect;
use Onnov\Captcha\Effect\WaveDistortionConfig;
use Onnov\Captcha\Effect\WaveDistortionEffect;

$waveDistortionConfig = (new WaveDistortionConfig())
            ->setAmplitudeStart(300)
            ->setAmplitudeEnd(500)
            ->setAmplitudeDivider(120);

$interferenceConfig = (new InterferenceConfig())
            ->setInterferenceMin(25)
            ->setInterferenceMax(35)
            ->setInterferenceSymbols(':#~');

$captchaConfig = (new CaptchaConfig())
            ->setEffects(
                [
                    new WaveDistortionEffect($waveDistortionConfig),
                    new InterferenceEffect($interferenceConfig),
                ]
            );

$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

### Basic captcha settings

[](#basic-captcha-settings)

- **setWidth(120)** // image width px
- **setHeight(50)** // image height px
- **setForegroundColor(\[0,0,0\])** // foreground color array \[R, G, B\]
- **setBackgroundColor(\[255,255,255\])** // background color array \[R, G, B\]
- **setAllowedSymbols('23456789')** // symbols used to draw CAPTCHA
- number of characters in captcha
    - **setLengthMin(4)** // minimum string length
    - **setLengthMax(5)** // maximum string length
- size gap between symbols
    - **setGapMin(0)** // minimum gap between symbols
    - **setGapMax(10)** // maximum gap between symbols
- **setFluctuationAmplitude(5)** // symbol's vertical fluctuation amplitude
- **setPadding(5)** // indent from the edge of the image to the inscription
- **setCharRotate(5)** // The angle in degrees for char rotation
- **setJpegQuality(70)** // JPEG quality of CAPTCHA image
- The script tries to return the image sequentially first in the GIF format then jpg further to the PNG
    - **setMaybeReturnGif(false)** // prevents the return of the image GIF
    - **setMaybeReturnJpg(false)** // prevents the return of the image JPG
    - **setMaybeReturnPng(false)** // prevents the return of the image PNG

configuration example

```
use Onnov\Captcha\CaptchaConfig;

$captchaConfig = (new CaptchaConfig())
            ->setWidth(120)
            ->setHeight(70)
            ->setPadding(5)
            ->setBackgroundColor([255,255,220])
            ->setForegroundColor([0,100,100]);

$result = $captcha
            ->setConfig($captchaConfig)
            ->getCaptcha();
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2454d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ce8cddb4adf802ec3b3653336dc25ac67f18363275b4f7813cb4e443e0140c4?d=identicon)[onnov](/maintainers/onnov)

---

Top Contributors

[![oka-volga](https://avatars.githubusercontent.com/u/3319885?v=4)](https://github.com/oka-volga "oka-volga (23 commits)")

---

Tags

spamcaptchaAbuse

### Embed Badge

![Health badge](/badges/onnov-captcha/health.svg)

```
[![Health](https://phpackages.com/badges/onnov-captcha/health.svg)](https://phpackages.com/packages/onnov-captcha)
```

###  Alternatives

[google/recaptcha

Client library for reCAPTCHA, a free service that protects websites from spam and abuse.

3.6k89.1M222](/packages/google-recaptcha)[gregwar/captcha

Captcha generator

1.8k9.6M138](/packages/gregwar-captcha)[gregwar/captcha-bundle

Captcha bundle

3524.7M32](/packages/gregwar-captcha-bundle)[karser/karser-recaptcha3-bundle

Google ReCAPTCHA v3 for Symfony

1862.4M7](/packages/karser-karser-recaptcha3-bundle)[usarise/turnstile

PHP library for Turnstile, is Cloudflare’s smart CAPTCHA alternative. It can be embedded into any website without sending traffic through Cloudflare and works without showing visitors a CAPTCHA.

2393.5k6](/packages/usarise-turnstile)[fabianwennink/iconcaptcha

IconCaptcha is a self-hosted, customizable, easy-to-implement and user-friendly captcha.

17740.5k1](/packages/fabianwennink-iconcaptcha)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
