authensure/authensure-php 问题修复 & 功能扩展

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

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

authensure/authensure-php

Composer 安装命令:

composer require authensure/authensure-php

包简介

Official PHP SDK for Authensure - Electronic signature and document authentication platform

README 文档

README

Packagist Version PHP Version License: MIT

Official PHP SDK for Authensure - the electronic signature and document authentication platform.

Features

  • Full API Coverage - Access all Authensure API endpoints
  • PHP 8.1+ - Modern PHP with strict typing
  • Automatic Retries - Built-in exponential backoff for transient errors
  • Rate Limit Handling - Automatic rate limit detection and backoff
  • Webhook Verification - Easy webhook signature verification
  • File Uploads - Simplified document upload handling with Guzzle
  • PSR Compliant - Built on PSR-7 HTTP message interfaces

Installation

composer require authensure/authensure-php

Quick Start

<?php

require_once 'vendor/autoload.php';

use Authensure\Client;

$client = Client::withApiKey('your_api_key');

// Create an envelope
$envelope = $client->envelopes->create([
    'name' => 'Contract Agreement',
    'message' => 'Please review and sign this document',
]);

echo "Created envelope: " . $envelope['id'];

Configuration

Global Configuration

use Authensure\Authensure;

Authensure::configure()
    ->setApiKey('your_api_key')
    ->setBaseUrl('https://api.authensure.app/api')
    ->setTimeout(30)
    ->setDebug(false);

$client = Authensure::client();

Per-Client Configuration

use Authensure\Client;
use Authensure\Configuration;

$config = new Configuration();
$config->setApiKey('your_api_key')
       ->setTimeout(30)
       ->setRetryAttempts(3);

$client = new Client($config);

API Reference

Envelopes

// List envelopes
$envelopes = $client->envelopes->list(['status' => 'DRAFT']);

// Get an envelope
$envelope = $client->envelopes->get('envelope_id');

// Create an envelope
$envelope = $client->envelopes->create([
    'name' => 'My Contract',
    'message' => 'Please sign',
]);

// Add a recipient
$recipient = $client->envelopes->addRecipient('envelope_id', [
    'email' => 'signer@example.com',
    'name' => 'John Doe',
    'role' => 'signer',
]);

// Send for signing
$envelope = $client->envelopes->send('envelope_id');

// Void an envelope
$envelope = $client->envelopes->void('envelope_id', 'Contract cancelled');

Documents

// Upload a document
$document = $client->documents->upload(
    'envelope_id',
    file_get_contents('contract.pdf'),
    'contract.pdf'
);

// Download a document
$content = $client->documents->download('document_id');
file_put_contents('signed_contract.pdf', $content);

Templates

// Use a template
$envelope = $client->templates->use('template_id', [
    'name' => 'New Contract',
    'recipients' => [
        ['roleId' => 'role_1', 'email' => 'signer@example.com', 'name' => 'John Doe'],
    ],
]);

Webhooks

// Create a webhook
$webhook = $client->webhooks->create([
    'url' => 'https://your-app.com/webhooks/authensure',
    'events' => ['envelope.signed', 'envelope.completed'],
]);

// Verify webhook signature
use Authensure\Resources\Webhooks;

$isValid = Webhooks::verifySignature($payload, $signature, 'your_webhook_secret');

// Construct verified event
$event = Webhooks::constructEvent($payload, $signature, 'your_webhook_secret');
echo "Event type: " . $event['event'];

Error Handling

use Authensure\Exceptions\AuthensureException;
use Authensure\Exceptions\NotFoundException;
use Authensure\Exceptions\AuthenticationException;
use Authensure\Exceptions\RateLimitException;
use Authensure\Exceptions\ValidationException;

try {
    $envelope = $client->envelopes->get('invalid_id');
} catch (NotFoundException $e) {
    echo "Envelope not found";
} catch (AuthenticationException $e) {
    echo "Invalid API key";
} catch (RateLimitException $e) {
    echo "Rate limited, retry after: " . $e->getRetryAfter() . " seconds";
} catch (ValidationException $e) {
    echo "Validation errors: " . print_r($e->getValidationErrors(), true);
} catch (AuthensureException $e) {
    echo "API error: " . $e->getMessage() . " (code: " . $e->getErrorCode() . ")";
}

Laravel Integration

Add to your config/services.php:

'authensure' => [
    'api_key' => env('AUTHENSURE_API_KEY'),
],

Create a service provider or use in your controller:

use Authensure\Client;

class EnvelopeController extends Controller
{
    private Client $authensure;

    public function __construct()
    {
        $this->authensure = Client::withApiKey(config('services.authensure.api_key'));
    }

    public function store(Request $request)
    {
        $envelope = $this->authensure->envelopes->create([
            'name' => $request->name,
            'message' => $request->message,
        ]);

        return response()->json($envelope);
    }
}

Development

# Install dependencies
composer install

# Run tests
composer test

# Run static analysis
composer phpstan

# Check code style
composer cs-check

Resources

License

This package is open-sourced software licensed under the MIT license.

authensure/authensure-php 适用场景与选型建议

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

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

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

围绕 authensure/authensure-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-07