Download the PHP package olakunlevpn/phpcapcha without Composer
On this page you can find all versions of the php package olakunlevpn/phpcapcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download olakunlevpn/phpcapcha
More information about olakunlevpn/phpcapcha
Files in olakunlevpn/phpcapcha
Package phpcapcha
Short Description PHP Captcha is an elegant, highly customizable, and secure captcha generator for PHP 8.0+. It supports advanced features like wave distortion, mathematical challenges, granular noise control, and custom font management.
License MIT
Informations about the package phpcapcha
Advanced PHP Captcha
PHP Captcha is an elegant, highly customizable, and secure captcha generator for PHP 8.0+. It supports advanced features like wave distortion, mathematical challenges, granular noise control, and custom font management.
Designed to be simple to use but powerful enough for any security requirement.
Requirements
- PHP 8.0 or higher
- GD Extension (
ext-gd)
Features
- Highly Customizable: Control colors, fonts, noise, lines, and distortion.
- Math Mode: Present users with simple arithmetic verification (e.g.,
5 + 3). - Wave Distortion: Advanced warp algorithms to defeat OCR bots.
- Font Management: Use a specific font or randomize from a directory.
- Multiple Outputs: Stream directly to browser, get Base64, or save to disk.
- Zero Dependencies: Requires only standard PHP GD extension.
Installation
You can install the package via composer:
Basic Usage
Here is the quickest way to get a captcha up and running:
Advanced Usage
Customizing Appearance
You can chain methods to configure the captcha exactly how you want it.
Math Challenge Mode
Instead of asking users to read distorted text, ask them to solve a simple math problem.
Granular Noise & Distortion Control
You have full control over the security elements.
To create a Clean captcha (easier for humans, less secure against bots):
Saving to File
Useful for caching or generating static assets.
Inline Base64
Useful for passing the image directly to a view or API response without a separate endpoint.
Validation
Validation is straightforward. Simply compare the user's input against the stored code.
API Reference
| Method | Description |
|---|---|
setFont(string $path) |
Path to a .ttf file OR a directory containing fonts (random selection). |
setTextColor(int $r, int $g, int $b) |
Sets the RGB color of the text. |
setBackgroundColor(int $r, int $g, int $b) |
Sets the RGB color of the background. |
setLength(int $length) |
Number of characters to generate (ignored in Math mode). |
setType(string $type) |
mixed (default), alpha, numeric, or math. |
setNoise(bool $enable, int $count) |
Toggle dots noise and set quantity. |
setLines(bool $enable, int $count) |
Toggle random lines and set quantity. |
setDistortion(bool $enable, int $amp, int $period) |
Toggle wave distortion. Amplitude/Period control wave shape. |
create(int $width, int $height) |
Generates the image resource. Must be called before output. |
output() |
Headers + Image binary stream (PNG). |
getBase64() |
Returns Base64 encoded string of the image. |
save(string $path) |
Saves the image to the specified file path. |
getCode() |
Returns the correct answer/code for validation. |
Examples
Check the examples/ directory for full implementations:
- Vanilla CSS (
examples/vanilla-css.php) - Tailwind CSS (
examples/tailwind.php) - Bootstrap 5 (
examples/bootstrap.php) - jQuery/AJAX (
examples/jquery.php)
AI assistant integration
This repository includes an AGENTS.md file specifically designed for AI assistants (like GitHub Copilot, Cursor, or Claude). If you're using an AI tool to help with your Laravel project:
- Point your AI assistant to the AGENTS.md file when asking about
phpcapchaoptimization. - The file contains detailed guidance for analyzing components and determining eligibility.
- Use it for automated analysis - AI assistants can help audit your entire component library.
Example prompts for AI assistants:
- "Using the
AGENTS.mdfile, analyze my components and tell me which can usephpcapcha" - "Help me add
phpcapchato all eligible components following the guidelines" - "Check if this component is safe for captcha protection based on
AGENTS.md"
License
The MIT License (MIT). Please see License File for more information.
All versions of phpcapcha with dependencies
ext-gd Version *