Skip to content

Commit 10d14e7

Browse files
author
wizard-ci[bot]
committed
wizard-ci: laravel/laravel12-saas
1 parent 2047145 commit 10d14e7

28 files changed

+3229
-101
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: laravel
3+
description: PostHog integration for Laravel applications
4+
metadata:
5+
author: PostHog
6+
version: dev
7+
---
8+
9+
# PostHog integration for Laravel
10+
11+
This skill helps you add PostHog analytics to Laravel applications.
12+
13+
## Workflow
14+
15+
Follow these steps in order to complete the integration:
16+
17+
1. `basic-integration-1.0-begin.md` - PostHog Setup - Begin ← **Start here**
18+
2. `basic-integration-1.1-edit.md` - PostHog Setup - Edit
19+
3. `basic-integration-1.2-revise.md` - PostHog Setup - Revise
20+
4. `basic-integration-1.3-conclude.md` - PostHog Setup - Conclusion
21+
22+
## Reference files
23+
24+
- `EXAMPLE.md` - Laravel example project code
25+
- `laravel.md` - Laravel - docs
26+
- `identify-users.md` - Identify users - docs
27+
- `basic-integration-1.0-begin.md` - PostHog setup - begin
28+
- `basic-integration-1.1-edit.md` - PostHog setup - edit
29+
- `basic-integration-1.2-revise.md` - PostHog setup - revise
30+
- `basic-integration-1.3-conclude.md` - PostHog setup - conclusion
31+
32+
The example project shows the target implementation pattern. Consult the documentation for API details.
33+
34+
## Key principles
35+
36+
- **Environment variables**: Always use environment variables for PostHog keys. Never hardcode them.
37+
- **Minimal changes**: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
38+
- **Match the example**: Your implementation should follow the example project's patterns as closely as possible.
39+
40+
## Framework guidelines
41+
42+
- Create a dedicated PostHogService class in app/Services/ - do NOT scatter PostHog::capture calls throughout controllers
43+
- Register PostHog configuration in config/posthog.php using env() for all settings (api_key, host, disabled)
44+
- Do NOT use Laravel's event system or observers for analytics - call capture explicitly where actions occur
45+
- Remember that source code is available in the vendor directory after composer install
46+
- posthog/posthog-php is the PHP SDK package name
47+
- Check composer.json for existing dependencies and autoload configuration before adding new files
48+
- The PHP SDK uses static methods (PostHog::capture, PostHog::identify) - initialize once with PostHog::init()
49+
- PHP SDK methods take associative arrays with 'distinctId', 'event', 'properties' keys - not positional arguments
50+
51+
## Identifying users
52+
53+
Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to maintain correlation.
54+
55+
## Error tracking
56+
57+
Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.

0 commit comments

Comments
 (0)