Repository navigation
feat(examples): use the posthog laravel sdk in the laravel example - #497
Conversation
The Laravel example moves to Laravel 12 and posthog/posthog-laravel, which replaces its hand-written init, middleware, exception callback and wrapper service. The Laravel rules and PHP best practices point agents at the SDK on Laravel 12+ and keep the manual PHP SDK setup for older apps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a wizard branch:
Add Results will be posted here when complete. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he token name Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eval results behind this stackThe changes in this stack came from running PostHog's install skills against real apps and grading each run. This comment has every result. What we ran
Findings and where the stack addressed them
Frontier agents, main arms
By agent and arm (frontier)
By app and arm (frontier)
Next.js reverse proxy (set up or suggested): firehose 2/6, stepwise 5/6 Firehose without the per-framework rules files (frontier, Next.js and Django)
OpenCode (Kimi K3), secondary
Every judged run
🤖 Generated with Claude Code |
gewenyu99
left a comment
There was a problem hiding this comment.
The Laravel example uses POSTHOG_API_KEY because that's what the SDK reads today. We call it the project token everywhere else now, so I'm going to open a PR to fix that at the source, and then we can switch this over. Thanks!
Problem
The Laravel example wires the plain PHP SDK by hand: its own init, request middleware, exception callback, config file and wrapper service. Agents copy it, so Laravel 12 and 13 apps get that hand-wiring instead of
posthog/posthog-laravel, which does all of it.Changes
posthog/posthog-laravel, set up withcomposer requireandphp artisan posthog:install. The init, middleware, exception callback andPostHogServiceare gone.POSTHOG_API_KEY, the name the released SDK reads, with the stock published config. feat: read the project token from POSTHOG_PROJECT_TOKEN posthog-php#311 moves the SDK toPOSTHOG_PROJECT_TOKEN, the name the other examples use. Once it ships, this example and the Laravel rules switch to it.PostHogfacade throughout.sdk-installrule now keeps an integration's own handling. The Laravel SDK sends each signed-out event with a fresh personless id.routes/api.phpusedauth:sanctumwithout Sanctum installed, so both API routes failed. They now use session auth.The Laravel SDK is labelled experimental on its docs page, which still offers the manual setup.
Stacked on #495.
How it was checked
composer installandcomposer auditin Docker/,/registerand/upreturn 200.posthog:doctorreports PostHog disablednpm test(320 passed) andnpm run buildNot run: delivery to a real PostHog project.
Agent context
Written by Claude Opus 5.5 (
claude-opus-5-5) in Claude Code. A Sonnet agent drafted the example port and ran the fake-host checks, and Opus reviewed it and wrote the rule changes.🤖 Generated with Claude Code