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

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

axyr/laravel-langfuse
=====================

Langfuse PHP SDK for Laravel

v0.1.0(2mo ago)121.8k↑2931.8%1MITPHPPHP ^8.2CI passing

Since Apr 3Pushed 2mo agoCompare

[ Source](https://github.com/axyr/laravel-langfuse)[ Packagist](https://packagist.org/packages/axyr/laravel-langfuse)[ RSS](/packages/axyr-laravel-langfuse/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

[![Laravel Langfuse](art/banner.png)](art/banner.png)

Laravel Langfuse
================

[](#laravel-langfuse)

[![CI](https://github.com/axyr/laravel-langfuse/actions/workflows/ci.yml/badge.svg)](https://github.com/axyr/laravel-langfuse/actions/workflows/ci.yml)[![PHPStan](https://camo.githubusercontent.com/83dd3d35cebed0eab9ee97ff1a5849c1344cda6a8ee9cac2cda20f5aa55b67bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)[![PHP Version](https://camo.githubusercontent.com/e97e1e8bebcb15031d35f381ed59dd1418cbbde99d0e5f9975d79e51e7398ba2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737374242342e7376673f7374796c653d666c6174266c6f676f3d706870)](https://www.php.net/)[![Laravel](https://camo.githubusercontent.com/57b6b23a62f21bd87ee18d297d4e50ee299cecfde72b8961d6207a196e654d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313225323025374325323031332d4646324432302e7376673f7374796c653d666c6174266c6f676f3d6c61726176656c)](https://laravel.com)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

[Langfuse](https://langfuse.com) is an open-source observability platform for LLM applications. It gives you a dashboard to trace every LLM call, track token usage and costs, manage prompt versions, and evaluate output quality - all in one place. It's self-hostable or available as a managed cloud service.

This package connects your Laravel app to Langfuse. Send traces, generations, scores, and prompts with a clean, idiomatic API - or let the auto-instrumentation do it for you.

```
use Axyr\Langfuse\LangfuseFacade as Langfuse;

$trace = Langfuse::trace(new TraceBody(name: 'chat-request'));

$generation = $trace->generation(new GenerationBody(
    name: 'chat',
    model: 'gpt-4',
    input: [['role' => 'user', 'content' => 'Hello!']],
));

// After the LLM responds:
$generation->end(
    output: 'Hi there!',
    usage: new Usage(input: 12, output: 85, total: 97),
);
```

Events are batched and flushed automatically. Zero-code auto-instrumentation is available for [Laravel AI](https://laravel.com/docs/ai-sdk), [Prism](https://github.com/prism-php/prism), and [Neuron AI](https://github.com/neuron-core/neuron-ai).

[![Langfuse trace view showing a RAG pipeline with nested spans, token usage, costs, and evaluation scores - all sent from Laravel](art/langfuse-screenshot.png)](art/langfuse-screenshot.png)

Features
--------

[](#features)

- **Full observability** - traces, spans, generations, events, and scores with automatic parent-child nesting
- **Prompt management** - fetch, cache, compile, create, and list prompts with stale-while-revalidate caching
- **Auto-instrumentation** - zero-code tracing for Prism, Laravel AI, and Neuron AI
- **Automatic batching** - events queued and sent in batches, with optional async dispatch via Laravel queues
- **Production-ready** - Octane compatible, graceful degradation, auto-flush on shutdown, testing fakes

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

[](#installation)

Requires PHP 8.2+ and Laravel 12 or 13.

**Langfuse Compatibility:** This package is compatible with both Langfuse v2 and v3. For self-hosted deployments, v3 introduces an asynchronous architecture with improved reliability and performance.

```
composer require axyr/laravel-langfuse
```

Add your Langfuse credentials to `.env`:

```
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
```

Optionally publish the configuration file:

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

Examples
--------

[](#examples)

Working example projects for each integration:

- [Laravel AI + Langfuse](https://github.com/axyr/laravel-langfuse-ai-examples) - agents, tools, streaming, and scoring with the official Laravel AI SDK
- [Prism + Langfuse](https://github.com/axyr/laravel-langfuse-prism-examples) - text, structured output, and streaming with Prism
- [Neuron AI + Langfuse](https://github.com/axyr/laravel-langfuse-neuron-ai-examples) - agent workflows with Neuron AI

Documentation
-------------

[](#documentation)

Full documentation in the [`docs/`](docs/README.md) directory:

- [Configuration](docs/configuration.md) - env vars, config publishing
- [Tracing](docs/tracing.md) - traces, updating, nesting observations
- [Generations](docs/generations.md) - LLM generation tracking, usage and cost
- [Spans and Events](docs/spans-and-events.md) - non-LLM work, event logging
- [Scores](docs/scores.md) - numeric, boolean, categorical scores
- [Prompt Management](docs/prompt-management.md) - fetch, cache, compile, create
- [Integrations](docs/integrations/prism.md) - Prism, Laravel AI, Neuron AI
- [Middleware](docs/middleware.md) - request trace context
- [Batching and Flushing](docs/batching-and-flushing.md) - flush control, queued dispatch
- [Testing](docs/testing.md) - fakes and assertions
- [Architecture](docs/architecture.md) - system diagram, Octane compatibility
- [Troubleshooting](docs/troubleshooting.md) - Langfuse v3 compatibility, common issues

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

[](#contributing)

Contributions welcome. Open an issue first to discuss what you'd like to change.

```
composer test        # Run tests
composer pint        # Fix code style
```

License
-------

[](#license)

MIT

Author
------

[](#author)

Built by [Martijn van Nieuwenhoven](https://martijnvannieuwenhoven.com) - Laravel developer specializing in AI integrations and observability tooling.

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

89d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/345155?v=4)[Martijn van Nieuwenhoven](/maintainers/axyr)[@axyr](https://github.com/axyr)

---

Top Contributors

[![axyr](https://avatars.githubusercontent.com/u/345155?v=4)](https://github.com/axyr "axyr (27 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M341](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M133](/packages/laravel-mcp)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M851](/packages/laravel-socialite)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[illuminate/routing

The Illuminate Routing package.

1419.2M2.9k](/packages/illuminate-routing)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

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