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.
- 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
⚡️ 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 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.