dropsolid / langfuse-php-sdk
A PHP SDK for the LangFuse API
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^12.0
This package is not auto-updated.
Last update: 2025-02-26 07:06:58 UTC
README
A PHP Client for LangFuse API
The LangFuse PHP SDK provides a convenient, object‐oriented way to interact with the LangFuse API from your PHP applications. This project is currently focused on the basics—allowing you to initialize a client and create simple traces with events—while laying the groundwork for more advanced features in future releases.
Overview
LangFuse is an observability and tracing platform designed to monitor complex LLM applications. This SDK enables PHP developers to:
- Initialize a LangFuse client with credentials and host configuration.
- Create traces and log events to track application execution.
- Later extend functionality to support nested spans, generations, scores, and other advanced observations.
The initial Minimum Viable Product (MVP) covers the essentials for tracing. Future versions will incrementally add more services and integrations.
MVP - aka - initial target for 0.1
Basic Client Configuration:
Configure via constructor arguments or environment variables:LANGFUSE_PUBLIC_KEY
LANGFUSE_SECRET_KEY
LANGFUSE_HOST
(defaults tohttps://cloud.langfuse.com
)
Tracing Service:
Create a trace and record basic events.Lightweight Error Handling:
Minimal custom exceptions for error reporting.
Requirements
- PHP 7.4 or higher
- Composer
- GuzzleHTTP for making HTTP requests
Installation (well, when it's ready)
You can install the SDK via Composer:
composer require dropsolid/langfuse-php-sdk
Current Status:
Under active development...
Roadmap (initial draft)
MVP 0.1 – Initial Implementation
- [ ] Basic Client:
- Initialization with credentials and host configuration.
- Configuration via environment variables and constructor.
- [ ] Tracing Service (Basic):
- Create traces.
- Log events.
- [ ] Minimal Error Handling:
- Basic exception classes for client errors.
MVP 0.2 – Enhanced Tracing
- [ ] Spans Support:
- Add methods to create and manage spans (start/end and nested spans).
- [ ] Generations:
- Support logging of AI model generations with additional metadata.
- [ ] Asynchronous Processing:
- Introduce a basic queue or background worker to send events asynchronously.
MVP 0.3 – Advanced Observability & Extensibility
- [ ] Additional API Endpoints:
- Implement support for Scores, Media, and other LangFuse API resources.
- [ ] Improved Error Handling and Retries:
- Enhance network error handling and implement configurable retries.
- [ ] Framework Integrations:
- Provide integration examples for popular PHP frameworks (e.g., Laravel, Symfony).
- [ ] Documentation and Testing:
- Expand usage examples, add more comprehensive tests, and improve developer documentation.
Future Versions
- [ ] Complete Feature Parity:
- Bring the SDK closer to the capabilities of the Python and TypeScript versions.
- [ ] Drupal Module Integration:
- Create a separate Drupal module that utilizes this SDK as a dependency.
- [ ] Community Contributions:
- Open the project for community feedback, pull requests, and additional integrations.