PHPackages                             janzaba/langfuse - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. janzaba/langfuse

ActiveLibrary[API Development](/categories/api)

janzaba/langfuse
================

A PHP library for interacting with the Langfuse API

0.0.4(1y ago)31.6k↓40.9%2[1 issues](https://github.com/janzaba/langfuse-php/issues)MITPHPPHP &gt;=8.1

Since Nov 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/janzaba/langfuse-php)[ Packagist](https://packagist.org/packages/janzaba/langfuse)[ RSS](/packages/janzaba-langfuse/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Langfuse OpenAI Middleware for PHP
==================================

[](#langfuse-openai-middleware-for-php)

Introduction
------------

[](#introduction)

This library provides wraper functions to use Langfuse LLM monitoring for your application. It was build for Symfony but can be used in any PHP application.

Installation
------------

[](#installation)

Install the library and required dependencies via Composer:

```
composer require janzaba/langfuse

```

Configuration in Symfony
------------------------

[](#configuration-in-symfony)

### Step 1: Define Environment Variables

[](#step-1-define-environment-variables)

In your `.env` file, add your Langfuse `PUBLIC_KEY` and `SECRET_KEY`:

```
LANGFUSE_PUBLIC_KEY=your-public-key
LANGFUSE_SECRET_KEY=your-secret-key
```

### Step 2: Register Services

[](#step-2-register-services)

In your `config/services.yaml`, add the following service definitions:

```
parameters:
    langfuse_config:
        public_key: '%env(LANGFUSE_PUBLIC_KEY)%'
        secret_key: '%env(LANGFUSE_SECRET_KEY)%'
        # Optional: langfuse_base_uri: 'https://custom.langfuse.endpoint/'

services:
        Langfuse\Config\Config:
        class: Langfuse\Config\Config
        arguments:
            - '%langfuse_config%'
        public: false

    Langfuse\Client\LangfuseClient:
        arguments:
            $config: '@Langfuse\Config\Config'

    Langfuse\LangfuseManager:
        arguments:
            $langfuseClient: '@Langfuse\Client\LangfuseClient'
```

### Step 3: Use the OpenAI Client in Your Services

[](#step-3-use-the-openai-client-in-your-services)

Now you can wrap your code with helper methods

#### Trace

[](#trace)

```
$this->langfuseManager->withTrace(
    'Trace name',
    ['operation' => 'example operation name'],
    function () {
        // Your code here
    }
);
```

#### Generation

[](#generation)

Inside a trace you can have LLM generation.

```
$answer = $this->langfuseManager->withGeneration(
    'prompt name',
    'gpt-4o-mini',
    $prompt,
    function () use ($prompt) {
        return $this->openAIClient->chat()->create(
            [
                'model' => 'gpt-4o-mini',
                'messages' => $prompt,
            ]
        );
    }
);
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue for any improvements or bugs.

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

549d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6c84205767845948fa04ac6f8c56c2e9a5382bd7829c0e98378b9135294e4b6?d=identicon)[janzaba](/maintainers/janzaba)

---

Top Contributors

[![janzaba](https://avatars.githubusercontent.com/u/7209239?v=4)](https://github.com/janzaba "janzaba (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/janzaba-langfuse/health.svg)

```
[![Health](https://phpackages.com/badges/janzaba-langfuse/health.svg)](https://phpackages.com/packages/janzaba-langfuse)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
