PHPackages                             dij-digital/langfuse-laravel - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. dij-digital/langfuse-laravel

ActiveLibrary[Localization &amp; i18n](/categories/localization)

dij-digital/langfuse-laravel
============================

This is my package langfuse-laravel

v0.2.0(2mo ago)102.3k↓40.9%1MITPHPPHP ^8.3||^8.4CI passing

Since Jun 30Pushed 2mo agoCompare

[ Source](https://github.com/DIJ-digital/langfuse-laravel)[ Packagist](https://packagist.org/packages/dij-digital/langfuse-laravel)[ Docs](https://github.com/dij-digital/langfuse-laravel)[ GitHub Sponsors]()[ RSS](/packages/dij-digital-langfuse-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (15)Versions (10)Used By (0)

Langfuse Laravel - A Laravel Facade for the PHP Langfuse API package.
---------------------------------------------------------------------

[](#langfuse-laravel---a-laravel-facade-for-the-php-langfuse-api-package)

This package provides a wrapper around the [langfuse-php](https://github.com/DIJ-digital/langfuse-php) package, allowing you to easily integrate Langfuse into your Laravel applications. It uses as few dependencies as possible.

[![Latest Version on Packagist](https://camo.githubusercontent.com/561fac1a96f95becb3e695ef99ec9bf195add5ea0422f2457ac6ae8e770ac2cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64696a2d6469676974616c2f6c616e67667573652d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dij-digital/langfuse-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6d8d6de7c78c2e2b6d3135a704e46f7bf29c544a3ec1c8233a256e0cbb8c5551/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64696a2d6469676974616c2f6c616e67667573652d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/dij-digital/langfuse-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/62f1b4dddd1ef1805f53b13f471ae50d69234ba445278600b461c2bcb7c4a00f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64696a2d6469676974616c2f6c616e67667573652d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/dij-digital/langfuse-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/2eadf99d5b9e2597e8a9adfd90fb6c4859586ce8090af7260cc356216e3606c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64696a2d6469676974616c2f6c616e67667573652d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dij-digital/langfuse-laravel)

### Features

[](#features)

- **Tracing** - Create traces, spans and generations that send directly to the Langfuse API
- **Prompts** - Fetch, compile and create text and chat prompts with fallback support
- Facade with direct access to `prompt()` and `ingestion()` methods

> **Requires [PHP 8.3](https://php.net/releases/) or [PHP 8.4](https://php.net/releases/) in combination with [Laravel 11](https://laravel.com/docs/11.x) or [Laravel 12](https://laravel.com/docs/12.x)**

### Installation

[](#installation)

```
composer require dij-digital/langfuse-laravel
```

### Configuration

[](#configuration)

Add the following environment variables to your `.env` file:

```
LANGFUSE_BASE_URI=https://cloud.langfuse.com
LANGFUSE_PUBLIC_KEY=
LANGFUSE_SECRET_KEY=

# Optional - defaults to config('app.env')
LANGFUSE_ENVIRONMENT=
```

Publish the config file (optional):

```
php artisan vendor:publish --tag=langfuse-laravel-config
```

### Usage

[](#usage)

#### Tracing

[](#tracing)

Every call sends directly to the Langfuse API. No buffering, no flushing.

```
use DIJ\Langfuse\Laravel\Facades\Langfuse;

// Create a trace
$trace = Langfuse::ingestion()->trace(name: 'handle-request', userId: 'user-1', input: 'hello');

// Nest spans and generations under the trace
$span = $trace->span(name: 'search');
$generation = $span->generation(
    input: 'prompt',
    output: 'response',
    name: 'llm',
    model: 'gpt-4o',
);

// Update any object (sends immediately)
$span->update(output: 'done', endTime: date('c'));
$trace->update(output: 'final answer');
```

#### Prompts

[](#prompts)

```
use DIJ\Langfuse\Laravel\Facades\Langfuse;

// Get and compile prompts
Langfuse::prompt()->text('promptName', fallback: 'fallback text')->compile(['key' => 'value']);
Langfuse::prompt()->chat('chatName', fallback: [['role' => 'user', 'content' => 'fallback']])->compile(['key' => 'value']);

// List all prompts (auto-paginated Generator)
foreach (Langfuse::prompt()->list() as $item) {
    echo $item->name;
}

// Create a prompt
Langfuse::prompt()->create('promptName', 'text', PromptType::TEXT);

// Update prompt labels
Langfuse::prompt()->update(promptName: 'promptName', version: 1, labels: ['production']);
```

#### Testing

[](#testing)

Use the `fake()` method to mock HTTP responses. The `langfuse-php` package ships with testing response helpers that provide sensible defaults — just override the fields you care about:

```
use DIJ\Langfuse\Laravel\Facades\Langfuse;
use DIJ\Langfuse\PHP\Testing\Responses\GetPromptResponse;

Langfuse::fake([
    new GetPromptResponse(data: [
        'name' => 'my-prompt',
        'type' => 'text',
        'prompt' => 'Hello {{name}}',
    ]),
]);

$prompt = Langfuse::prompt()->text('my-prompt');
```

Available test response helpers in `DIJ\Langfuse\PHP\Testing\Responses`:

- `GetPromptResponse` — text prompt fetch
- `GetChatPromptResponse` — chat prompt fetch
- `NoPromptFoundResponse` — 404 prompt not found
- `PostPromptResponse` — text prompt creation
- `PostChatPromptResponse` — chat prompt creation
- `PatchPromptLabelsResponse` — prompt label update
- `GetPromptListPageOneResponse` — first page of prompt list
- `GetPromptListPageTwoResponse` — second page of prompt list

Responses are consumed sequentially (Guzzle `MockHandler`), so the order of responses must match the order of HTTP calls your code makes.

### Development

[](#development)

```
composer test        # Run tests
composer codestyle   # Format, refactor and analyse
```

#### Ingestion

[](#ingestion)

```
use DIJ\Langfuse\Laravel\Facades\Langfuse;

// Creates a trace and a generation visible in Langfuse UI
$traceId = 'trace-id-123';

Langfuse::ingestion()->trace(
    input: 'prompt text',
    output: null,
    traceId: $traceId,
    name: 'name',
    sessionId: null,
    metadata: ['key' => 'value']
);

Langfuse::ingestion()->generation(
    input: 'prompt text',
    output: 'model output',
    traceId: $traceId,
    name: 'name',
    sessionId: null,
    promptName: 'promptName',
    promptVersion: 1,
    model: 'gpt-4o',
    modelParameters: ['temperature' => 0.7],
    metadata: ['key' => 'value']
);
```

**Langfuse Laravel** was created by **[Tycho Engberink](https://github.com/tychoengberinkDIJ)** and is maintained by **[DIJ Digital](https://dij.digital)** under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance83

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75.5% 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 ~47 days

Recently: every ~58 days

Total

6

Last Release

88d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ab892324187874b808c0bd037ff12f74fcb3257f0cf8d9723bbd30768d482ac?d=identicon)[DIJ](/maintainers/DIJ)

---

Top Contributors

[![tychoengberinkDIJ](https://avatars.githubusercontent.com/u/122891499?v=4)](https://github.com/tychoengberinkDIJ "tychoengberinkDIJ (40 commits)")[![jesse-bos](https://avatars.githubusercontent.com/u/131663982?v=4)](https://github.com/jesse-bos "jesse-bos (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![jesse-bos-dij](https://avatars.githubusercontent.com/u/169130613?v=4)](https://github.com/jesse-bos-dij "jesse-bos-dij (1 commits)")

---

Tags

laravellangfuseDIJ Digital

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/dij-digital-langfuse-laravel/health.svg)

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

###  Alternatives

[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

590244.8k1](/packages/askdkc-breezejp)[statikbe/laravel-filament-chained-translation-manager

A translation manager tool for Laravel Filament, that makes use of the Laravel Chained Translator.

92108.7k](/packages/statikbe-laravel-filament-chained-translation-manager)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[elegantly/laravel-translator

All on one translations management for Laravel

6216.9k](/packages/elegantly-laravel-translator)[andrewdwallo/transmatic

Automate and streamline real-time text translations in your Laravel applications

5511.6k](/packages/andrewdwallo-transmatic)[smousss/laravel-globalize

Make Laravel projects translatable in a matter of seconds!

2266.3k](/packages/smousss-laravel-globalize)

PHPackages © 2026

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