PHPackages                             magkopian/php-math-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. magkopian/php-math-captcha

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

magkopian/php-math-captcha
==========================

A simple class for generating and validating math captcha images

1.0.0(11y ago)51.9k3MITPHPPHP &gt;=5.0.0

Since Oct 4Pushed 8y ago3 watchersCompare

[ Source](https://github.com/magkopian/php-math-captcha)[ Packagist](https://packagist.org/packages/magkopian/php-math-captcha)[ RSS](/packages/magkopian-php-math-captcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Description:
------------

[](#description)

This is a PHP class for generating images with simple mathematical questions (Math CAPTCHAs) to protect the forms of your website from spambots.

How to Install:
---------------

[](#how-to-install)

You can install the class very easily by using composer. You just have to run:

`composer require magkopian/php-math-captcha:1.0.*`

Or add it as a dependency in you `composer.json` file:

```
{
	"require": {
		"magkopian/php-math-captcha": "1.0.*"
	}
}
```

And then run:

`composer update`

Also, don't forget to include composer `autoload.php` file to your code.

How to Use:
-----------

[](#how-to-use)

To generate a captcha you simply:

```
session_start();

$mathCaptcha = new MathCaptcha\MathCaptcha();

$mathCaptcha->generate();
$mathCaptcha->output();
```

The `MathCaptcha` class makes use of session variables so you have to call the `session_start()` function before instantiating a `MathCaptcha` object.

You can optionally supply an identifier for the captcha, to the constructor of the `MathCaptcha` class, if you want to use multiple captchas in your website.

To verify the user's answer you simply:

```
session_start();

$mathCaptcha = new MathCaptcha\MathCaptcha();

if ( $mathCaptcha->check($captcha_answer) === true ) {
	// Correct answer
}
else {
	// Incorrect answer
}
```

If you use more than one captchas in your website you need also to supply the identifier of the captcha, to the constructor of the `MathCaptcha` class.

Check out the `test_form.php` and `math_captcha.php` files for a working example.

Requirements:
-------------

[](#requirements)

PHP 5, GD 2.0.1 or later (2.0.28 or later is recommended)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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

Unknown

Total

1

Last Release

4244d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a652fde0e526b6fe885e53d76db20402703583f2a9b072a4ef8276559632a1d1?d=identicon)[magkopian](/maintainers/magkopian)

---

Top Contributors

[![magkopian](https://avatars.githubusercontent.com/u/1429068?v=4)](https://github.com/magkopian "magkopian (22 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

captchamath captchaantispamcaptcha class

### Embed Badge

![Health badge](/badges/magkopian-php-math-captcha/health.svg)

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

###  Alternatives

[bonecms/laravel-captcha

Captcha integration for Laravel

76138.4k](/packages/bonecms-laravel-captcha)[pixelopen/cloudflare-turnstile-bundle

A simple package to help integrate Cloudflare Turnstile on Symfony.

31205.8k3](/packages/pixelopen-cloudflare-turnstile-bundle)[lubosdz/yii2-captcha-extended

Extended captcha code generator for Yii2 framework with configurable obfuscation level

1117.4k](/packages/lubosdz-yii2-captcha-extended)[webman/captcha

Captcha generator

1484.2k25](/packages/webman-captcha)[isszz/rotate-captcha

Rotate image captcha

801.7k](/packages/isszz-rotate-captcha)[haruncpi/laravel-simple-captcha

A laravel simple captcha package

1128.3k](/packages/haruncpi-laravel-simple-captcha)

PHPackages © 2026

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