logseal/logseal-php
Composer 安装命令:
composer require logseal/logseal-php
包简介
Official PHP SDK for LogSeal — Audit logging for B2B SaaS
README 文档
README
Official PHP SDK for LogSeal — Audit logging for B2B SaaS.
Installation
composer require logseal/logseal-php
Quick Start
use LogSeal\LogSeal; $client = new LogSeal('sk_test_...'); // Emit an event (batched) $client->emit([ 'action' => 'document.published', 'organization_id' => 'org_acme', 'actor' => [ 'id' => 'user_123', 'name' => 'Jane Smith', 'email' => 'jane@acme.com', ], 'targets' => [[ 'type' => 'document', 'id' => 'doc_456', 'name' => 'Q3 Report', ]], 'metadata' => [ 'previous_status' => 'draft', ], ]); // Emit and wait for confirmation $event = $client->emitSync([ 'action' => 'user.deleted', 'organization_id' => 'org_acme', 'actor' => ['id' => 'admin_1'], 'targets' => [['type' => 'user', 'id' => 'user_123']], ]); echo "Event ID: " . $event['id'] . "\n"; // Flush remaining events before exit $client->shutdown();
Configuration
$client = new LogSeal('sk_live_...', [ 'base_url' => 'https://api.logseal.io', // Optional override 'batch_size' => 100, // Events to buffer before auto-flushing 'max_retries' => 3, // Retry attempts on 429 / 5xx responses 'timeout' => 30, // HTTP timeout in seconds ]);
Querying Events
// Paginated list $page = $client->events->list([ 'organization_id' => 'org_acme', 'action' => 'document.published', 'limit' => 50, ]); foreach ($page['data'] as $event) { echo $event['action'] . ' by ' . $event['actor']['name'] . "\n"; } // Auto-paginate through all results (Generator) foreach ($client->events->listAll(['organization_id' => 'org_acme']) as $event) { echo $event['action'] . "\n"; }
Organizations
$orgs = $client->organizations->list(); $org = $client->organizations->create('acme', 'Acme Corp'); $org = $client->organizations->get('org_123');
Event Schemas
$schemas = $client->schemas->list(); $schema = $client->schemas->create('document.updated', 'Fired when a document is modified', ['document']); $schema = $client->schemas->update('sch_123', ['description' => 'Updated desc']); $client->schemas->delete('sch_123');
Viewer Tokens
$token = $client->viewerTokens->create('org_acme', 3600); // Pass $token['token'] to your frontend for the embeddable viewer
Webhooks
$webhooks = $client->webhooks->list(); $webhook = $client->webhooks->create('https://example.com/webhooks/logseal', null, ['*']); echo "Secret: " . $webhook['secret'] . "\n"; // Only returned on creation $client->webhooks->update('whk_123', ['enabled' => false]); $client->webhooks->delete('whk_123');
Exports
$export = $client->exports->create('org_acme', 'csv', ['after' => '2024-01-01']); // Poll until complete $completed = $client->exports->poll($export['id'], intervalSeconds: 1, timeoutSeconds: 120); echo "Download: " . $completed['download_url'] . "\n";
Verification
$result = $client->events->verify('org_acme'); echo $result['status']; // "valid", "broken", or "tampered"
Error Handling
use LogSeal\Exception\LogSealException; try { $client->emitSync([...]); } catch (LogSealException $e) { echo "[{$e->type}] {$e->code}: {$e->getMessage()}\n"; echo "HTTP status: {$e->statusCode}\n"; }
All API errors are thrown as LogSealException:
| Property | Description |
|---|---|
$type |
Error category (authentication_error, validation_error, etc.) |
$errorCode |
Machine-readable code (invalid_api_key, missing_required_field, etc.) |
getMessage() |
Human-readable description |
$param |
Request parameter that caused the error (if applicable) |
$statusCode |
HTTP status code |
Requirements
- PHP 8.1+
- Guzzle 7.x
License
MIT
logseal/logseal-php 适用场景与选型建议
logseal/logseal-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「Audit」 「saas」 「b2b」 「compliance」 「audit-log」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 logseal/logseal-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 logseal/logseal-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 logseal/logseal-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Log adding/updating/deleting of elements
Doctrine ORM provider for the auditor audit-log library.
A Zend Framework module that sets up Monolog for logging in applications.
PB Web Media Audit Bundle for Symfony
Laravel Plans is a package for SaaS apps that need management over plans, features, subscriptions, events for plans or limited, countable features.
Asynchronous Sentry for Symfony - Fire and forget
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-06