eprofos/captcha 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eprofos/captcha

Composer 安装命令:

composer require eprofos/captcha

包简介

A professional PHP 8+ library for generating visually sophisticated captchas with advanced security features and accessibility options

README 文档

README

A professional PHP 8+ library for generating visually sophisticated captchas.

Features

  • Generation of visually sophisticated captchas
  • Complete customization (dimensions, fonts, complexity levels, etc.)
  • Distortion and wave effects
  • Background noise and pattern options
  • Color schemes and gradient options
  • Character set and length configuration
  • Session integration capabilities
  • Implementation with modern PHP 8 features (attributes, typed properties, union types)

Installation

composer require eprofos/captcha

Requirements

  • PHP 8.0 or higher
  • GD extension
  • mbstring extension

Basic Usage

<?php

use Eprofos\Captcha\Captcha;
use Eprofos\Captcha\Config\CaptchaConfig;

// Create a captcha configuration
$config = new CaptchaConfig();
$config->setWidth(200)
       ->setHeight(80)
       ->setLength(6)
       ->setComplexity(CaptchaConfig::COMPLEXITY_MEDIUM);

// Create a captcha instance
$captcha = new Captcha($config);

// Generate and display the captcha
$captcha->generate();
$captcha->output();

// Store the code in the session
$_SESSION['captcha_code'] = $captcha->getCode();

Captcha Verification

<?php

// Verify the submitted captcha code
$userInput = $_POST['captcha'] ?? '';
$storedCode = $_SESSION['captcha_code'] ?? '';

if (strtolower($userInput) === strtolower($storedCode)) {
    echo "Captcha validated successfully!";
} else {
    echo "Incorrect captcha code!";
}

Advanced Customization

<?php

use Eprofos\Captcha\Captcha;
use Eprofos\Captcha\Config\CaptchaConfig;
use Eprofos\Captcha\Config\ColorScheme;

// Create a custom configuration
$config = new CaptchaConfig();
$config->setWidth(300)
       ->setHeight(100)
       ->setLength(8)
       ->setComplexity(CaptchaConfig::COMPLEXITY_HIGH)
       ->setFont('montserrat.ttf')
       ->setBackgroundNoise(true)
       ->setWaveDistortion(true)
       ->setCharacterSet('ABCDEFGHJKLMNPQRSTUVWXYZ23456789')
       ->setColorScheme(new ColorScheme('#3498db', '#2c3e50'));

// Create and generate the captcha
$captcha = new Captcha($config);
$captcha->generate();

// Save the image
$captcha->save('/path/to/captcha.png');

// Or send the image as an HTTP response
$captcha->output();

Using with Built-in Session Storage

<?php

use Eprofos\Captcha\Captcha;
use Eprofos\Captcha\Config\CaptchaConfig;
use Eprofos\Captcha\Storage\SessionStorage;

// Start the session
session_start();

// Create a configuration
$config = new CaptchaConfig();

// Create a captcha with session storage
$storage = new SessionStorage('my_captcha_key');
$captcha = new Captcha($config, $storage);

// Generate and display the captcha
$captcha->generate();
$captcha->output();

// Verify the code (in another script)
if ($captcha->verify($_POST['captcha'] ?? '')) {
    echo "Captcha validated successfully!";
} else {
    echo "Incorrect captcha code!";
}

License

MIT

eprofos/captcha 适用场景与选型建议

eprofos/captcha 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「security」 「Authentication」 「captcha」 「anti-spam」 「accessibility」 「verification」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 eprofos/captcha 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 eprofos/captcha 我们能提供哪些服务?
定制开发 / 二次开发

基于 eprofos/captcha 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-08