dropsolid/langfuse-php-sdk
Composer 安装命令:
composer require dropsolid/langfuse-php-sdk
包简介
A PHP SDK for the LangFuse API
README 文档
README
A PHP Client for LangFuse API
This SDK provides a convenient, object‐oriented way to interact with the LangFuse API from your PHP applications. It supports creating and managing traces, spans, generations, events, and scores, and includes integration tests for validation. Test.
Current Implementation (v1.1.0)
- [x] Basic client initialization (keys, host, etc.)
- [x] Tracing service (traces, spans, generations, scores, events)
- [x] Batch (accumulated) sync of traces
- [x] Comprehensive tests (unit and integration)
- [x] SOLID architecture with dependency injection
- [x] Advanced retry logic with circuit breaker patterns
- [x] PHP 8.1+ support
- [x] Strong typing with DTOs and enhanced error handling
- [x] Per-request timeout override capabilities
- [x] User-Agent headers with SDK identification
Installation
Install via Composer:
composer require dropsolid/langfuse-php-sdk
Requirements:
• PHP 8.1+
• GuzzleHTTP
Usage
Configure via environment variables or direct constructor args:
LANGFUSE_PUBLIC_KEY="..." LANGFUSE_SECRET_KEY="..." LANGFUSE_HOST="..."Create a client and use the tracing service for all trace operations.
Advanced: Per-Sync Timeout Override
$client = new Client(['timeout' => 20.0]); // Global default // Quick sync with short timeout $client->trace('urgent-operation'); $client->syncTraces(['timeout' => 5.0]); // Large batch with extended timeout $client->trace('bulk-operation'); $client->syncTraces(['timeout' => 60.0]);
Roadmap
🎯 v1.1.0 - Quality & Type Safety ✅ COMPLETED
RELEASE NOTES: All v1.1.0 features successfully implemented and tested! This major update transforms the SDK into an enterprise-ready solution with comprehensive type safety, advanced error handling, and flexible configuration options.
Must-Have (Quality Essentials) - ALL COMPLETE:
- [x] Strong Typing & DTOs - Add typed request/response objects for all operations
- [x] Enhanced Error Handling - Specific exception types with detailed context (ApiError, NetworkError, ValidationError)
- [x] User-Agent Headers - Add proper SDK identification headers
- [x] SOLID Architecture - Dependency injection and interface-based design
- [x] PHP 8.1+ Requirement - Upgrade minimum version for better typing support
Should-Have (Configuration Improvements) - ALL COMPLETE:
- [x] Per-Request Timeout Override - Allow custom timeouts per operation
- [x] Retry Configuration - Configurable retry logic with exponential backoff
- [x] Circuit Breaker Pattern - Automatic failure detection with recovery
🚀 Next Features - Core Feature Expansion
Target: Essential missing observability features we plan to work on next
- [ ] Request/Response Logging - Optional debug logging for troubleshooting
- [ ] Session Management - Create and manage user sessions
- [ ] Dataset Support - Basic dataset creation and item management
- [ ] Prompt Management - Create, retrieve, and version prompts
- [ ] Expanded Model Configuration - Enhanced model definitions and management
- [ ] Advanced Filtering - Add filtering options to trace/observation queries
- [ ] Pagination Support - Handle large result sets efficiently
🔮 Backlog - Future Considerations
Features we might consider in the future. Community contributions welcome!
These features are inspired by the Python SDK but may never be implemented depending on demand and priorities. If your company finds any of these critical, please open an issue to help us prioritize, or feel free to submit a PR - it's open source after all!
Performance & Async:
- Async support (ReactPHP/Amp) for non-blocking operations
- Connection pooling and memory optimization
- Background processing and batch size configuration
Advanced Configuration:
- Proxy support and custom middleware
- Compression support for large payloads
Extended Features:
- Media management (upload/manage media files)
- Analytics queries and advanced reporting
- Webhook support for incoming Langfuse events
- Data export in various formats
- Multi-project support in single client
Enterprise Features:
- Health check endpoints and metrics collection
- Custom serialization strategies
- Advanced debugging and monitoring tools
dropsolid/langfuse-php-sdk 适用场景与选型建议
dropsolid/langfuse-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35.95k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「langfuse」 「langfuse php」 「langfuse sdk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dropsolid/langfuse-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dropsolid/langfuse-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dropsolid/langfuse-php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A langfuse wrapper for PHP
This is my package langfuse-laravel
Seamless integration of Langfuse observability for Laravel and Laravel Prism.
Alfabank REST API integration
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
A lightweight PHP logger for Langfuse to track LLM API calls (OpenAI, Claude, Gemini, Grok) with token usage analytics
统计信息
- 总下载量: 35.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-25