Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ Thanks for your interest in improving the PostHog PHP SDK.
composer install --prefer-dist --no-progress
```

## Running the example app

1. Copy `.env.example` to `.env` and add your PostHog credentials.
2. Run the interactive example script:

```bash
php example.php
```

## CI-aligned checks

Run the test command used in CI:
Expand Down
47 changes: 3 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,12 @@ Specifically, the [PHP integration](https://posthog.com/docs/integrations/php-in
## Features

- ✅ Event capture and user identification
- ✅ Error tracking with manual exception capture
- ✅ Opt-in automatic PHP exception, error, and fatal shutdown capture
- ✅ Feature flag local evaluation
- ✅ **Feature flag dependencies** (new!) - Create conditional flags based on other flags
- ✅ Multivariate flags and payloads
- ✅ Feature flags, including local evaluation, multivariate flags, payloads, and flag dependencies
- ✅ Group analytics
- ✅ Error tracking with manual exception capture and opt-in automatic PHP exception, error, and fatal shutdown capture
- ✅ Request context helpers for applying distinct IDs, session IDs, and common properties across a request
- ✅ Comprehensive test coverage

## Quick Start

1. Copy `.env.example` to `.env` and add your PostHog credentials
2. Run `php example.php` to see interactive examples of all features

## Error Tracking

Manual exception capture:

```php
PostHog::captureException($exception, 'user-123', [
'$current_url' => 'https://example.com/settings',
]);
```

Opt-in automatic capture from the core SDK:

```php
PostHog::init('phc_xxx', [
'error_tracking' => [
'enabled' => true,
'capture_errors' => true,
'excluded_exceptions' => [
\InvalidArgumentException::class,
],
'context_provider' => static function (array $payload): array {
return [
'distinctId' => $_SESSION['user_id'] ?? null,
'properties' => [
'$current_url' => $_SERVER['REQUEST_URI'] ?? null,
],
];
},
],
]);
```

Auto error tracking is off by default. When enabled, the SDK chains existing exception and error handlers instead of replacing app behavior.

## Questions?

### [Join our Slack community.](https://join.slack.com/t/posthogusers/shared_invite/enQtOTY0MzU5NjAwMDY3LTc2MWQ0OTZlNjhkODk3ZDI3NDVjMDE1YjgxY2I4ZjI4MzJhZmVmNjJkN2NmMGJmMzc2N2U3Yjc3ZjI5NGFlZDQ)
Expand Down
Loading
Loading