dij-digital / langfuse-php
A langfuse wrapper for PHP
dev-master
2025-06-25 13:59 UTC
Requires
- php: ^8.3|^8.4
- guzzlehttp/guzzle: ^7.9
Requires (Dev)
- laravel/pint: ^1.22.1
- peckphp/peck: ^0.1.3
- pestphp/pest: ^3.8.0
- pestphp/pest-plugin-type-coverage: ^3.5.0
- phpstan/phpstan: ^2.1.16
- rector/rector: ^2.0.16
- symfony/var-dumper: ^7.2.6
This package is auto-updated.
Last update: 2025-06-25 13:59:51 UTC
README
This package provides a wrapper around the Langfuse Api, allowing you to easily integrate Langfuse into your PHP applications. It uses as few dependencies as possible.
It supports the following features:
- Getting a text prompt
- Getting a chat prompt
- Compiling a text prompt
- Compiling a chat prompt
- Create a text prompt
- Create a chat prompt
- Fallbacks for prompt fetching when an error occurs
- Fallbacks for prompt fetching when no prompt is found
Requires PHP 8.4
⚡️ Install the package using Composer:
composer require dij-digital/langfuse-php
🤙 Modern codebase , refactoring and static analysis in one command
composer codestyle
🚀 Run the entire test suite:
composer test
How to use this package
use DIJ\Langfuse\PHP; use DIJ\Langfuse\PHP\Transporters\HttpTransporter; use GuzzleHttp\Client; $langfuse = new Langfuse(new HttpTransporter(new Client([ 'base_uri' => 'https://cloud.langfuse.com', //choose as needed 'auth' => ['PUBLIC_KEY', 'SECRET_KEY'], //generate a set in your project ]))); $langfuse->prompt()->text('promptName')->compile(['key' => 'value']); $langfuse->prompt()->text('promptName')->compile(['key' => 'value']); $langfuse->prompt()->chat('chatName')->compile(['key' => 'value']); $langfuse->prompt()->list(); $langfuse->prompt()->create('promptName', 'text', PromptType::TEXT);
Langfuse PHP was created by Tycho Engberink under the MIT license.