{"id":36995068,"url":"https://github.com/mtyrtov/langfuse-php","last_synced_at":"2026-01-13T23:47:22.719Z","repository":{"id":295805214,"uuid":"970242906","full_name":"mtyrtov/langfuse-php","owner":"mtyrtov","description":"PHP SDK for Langfuse - LLM tracing, scores, annotation queues, dataset runs and prompt management","archived":false,"fork":false,"pushed_at":"2025-06-19T12:43:45.000Z","size":39,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-16T23:47:56.740Z","etag":null,"topics":["ai","langfuse","llm","php","sdk"],"latest_commit_sha":null,"homepage":"https://tyrtov.tech/packagist/langfuse-php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtyrtov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-21T17:51:59.000Z","updated_at":"2025-06-19T12:43:48.000Z","dependencies_parsed_at":"2025-06-12T17:33:43.195Z","dependency_job_id":"1cf37317-fe09-4255-9690-a20f3a1318f3","html_url":"https://github.com/mtyrtov/langfuse-php","commit_stats":null,"previous_names":["mtyrtov/langfuse-php"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mtyrtov/langfuse-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtyrtov%2Flangfuse-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtyrtov%2Flangfuse-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtyrtov%2Flangfuse-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtyrtov%2Flangfuse-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtyrtov","download_url":"https://codeload.github.com/mtyrtov/langfuse-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtyrtov%2Flangfuse-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","langfuse","llm","php","sdk"],"created_at":"2026-01-13T23:47:22.271Z","updated_at":"2026-01-13T23:47:22.714Z","avatar_url":"https://github.com/mtyrtov.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Langfuse PHP SDK\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/mtyrtov/langfuse-php.svg?style=flat-square)](https://packagist.org/packages/mtyrtov/langfuse-php)\n[![Total Downloads](https://img.shields.io/packagist/dt/mtyrtov/langfuse-php.svg?style=flat-square)](https://packagist.org/packages/mtyrtov/langfuse-php)\n[![PHP Version Require](https://img.shields.io/packagist/php-v/mtyrtov/langfuse-php?style=flat-square)](https://packagist.org/packages/mtyrtov/langfuse-php)\n[![License](https://img.shields.io/packagist/l/mtyrtov/langfuse-php.svg?style=flat-square)](https://packagist.org/packages/mtyrtov/langfuse-php)\n\nA PHP SDK for interacting with the Langfuse API. This package provides tools for tracing, scores, annotation queues, dataset runs and prompt management to enable comprehensive LLM observability.\n\n## Requirements\n\n- PHP \u003e= 8.1\n\n## Installation\n\n```bash\ncomposer require mtyrtov/langfuse-php:dev-master\n```\n\n## Quick Start\n\n```php\nuse Langfuse\\LangfuseClient;\nuse Langfuse\\LangfuseProfiler;\n\nrequire_once \"vendor/autoload.php\";\n\n# Initialize the client\n$client = new LangfuseClient(\n    'your-public-key',\n    'your-secret-key',\n    'https://your-langfuse-host.com' # Optional, defaults to http://127.0.0.1:3000\n);\n\n$profiler = new LangfuseProfiler($client);\n```\n\n## Core Features\n\n### Tracing\n\nTraces represent full user sessions or requests in your application.\n\n```php\n# Create a trace\n$trace = $profiler-\u003etrace('user-query')\n    -\u003esetSessionId() // Automatically generates a session ID\n    -\u003esetUserId('user-123');\n\n# Set input and output\n$trace-\u003esetInput('Hello, how are you?');\n$trace-\u003esetOutput(\"I'm fine, thank you!\");\n```\n\n### Spans\n\nSpans represent logical sections within a trace, such as specific processing steps.\n\n```php\n# Create a span within a trace\n$classificationSpan = $trace-\u003espan('classification');\n\n# End the span when the operation is complete\n$classificationSpan-\u003eend();\n```\n\n### Generations\n\nGenerations track individual LLM calls and their results.\n\n```php\n# Create a generation within a span\n$generation = $classificationSpan-\u003egeneration('model-call')\n    -\u003ewithModel('gpt-4.1-mini')\n    -\u003ewithModelParameters(['temperature' =\u003e 0])\n    -\u003esetInput(['role' =\u003e 'user', 'content' =\u003e 'Hello there'])\n    -\u003esetOutput('AI response here');\n```\n\n### Flushing Data\n\nEnsure all data is sent to Langfuse before your application terminates.\n\n```php\n$result = $profiler-\u003eflush();\n```\n\n## Laravel\n```php\nclass LangfuseProvider extends ServiceProvider\n{\n    public function register(): void\n    {\n        $this-\u003eapp-\u003esingleton(LangfuseClient::class, function ($app) {\n            return new LangfuseClient(\n                # Your variables from .env\n                config('services.langfuse.public_key'),\n                config('services.langfuse.secret_key'),\n                config('services.langfuse.base_uri')\n            );\n        });\n\n        $this-\u003eapp-\u003esingleton(LangfuseProfiler::class, function ($app) {\n            return new LangfuseProfiler($app-\u003emake(LangfuseClient::class));\n        });\n    }\n\n    public function boot(): void\n    {\n        //\n    }\n}\n```\n\n## Advanced Usage\n\n### Working with Multiple Generations\n\n```php\n# Create multiple generations within a span\n$generation1 = $trace-\u003espan('classification')-\u003egeneration('generation-1')\n    -\u003esetModel('gpt-4.1-mini')\n    -\u003esetModelParameters(['temperature' =\u003e 0.5])\n    -\u003esetPrompt($prompt)\n    -\u003esetInput($messages)\n    -\u003esetOutput('RESULT_1');\n\n$generation2 = $trace-\u003espan('classification')-\u003egeneration('generation-2')\n    -\u003esetModel('gpt-4.1-nano')\n    -\u003esetModelParameters(['temperature' =\u003e 0])\n    -\u003esetPrompt($prompt)\n    -\u003esetInput($messages)\n    -\u003esetOutput('RESULT_2');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtyrtov%2Flangfuse-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtyrtov%2Flangfuse-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtyrtov%2Flangfuse-php/lists"}