PHPackages                             posthog/posthog-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. posthog/posthog-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

posthog/posthog-php
===================

PostHog PHP Library

4.0.3(2mo ago)293.5M—4.5%30[6 PRs](https://github.com/PostHog/posthog-php/pulls)6MITPHPPHP &gt;=8.2CI passing

Since May 22Pushed 2mo ago13 watchersCompare

[ Source](https://github.com/PostHog/posthog-php)[ Packagist](https://packagist.org/packages/posthog/posthog-php)[ Docs](https://github.com/PostHog/posthog-php)[ RSS](/packages/posthog-posthog-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (93)Used By (6)

PostHog PHP
===========

[](#posthog-php)

[![PHP Version](https://camo.githubusercontent.com/0353adf59366cbf52f7c4dcbbdc80d4e158bada4a26631181b996a894286515c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706f7374686f672f706f7374686f672d7068703f6c6f676f3d706870)](https://packagist.org/packages/posthog/posthog-php)[![CI](https://github.com/PostHog/posthog-php/actions/workflows/php.yml/badge.svg)](https://github.com/PostHog/posthog-php/actions/workflows/php.yml)

Please see the main [PostHog docs](https://posthog.com/docs).

Specifically, the [PHP integration](https://posthog.com/docs/integrations/php-integration) details.

Features
--------

[](#features)

- ✅ Event capture and user identification
- ✅ Feature flag local evaluation
- ✅ **Feature flag dependencies** (new!) - Create conditional flags based on other flags
- ✅ Multivariate flags and payloads
- ✅ Group analytics
- ✅ Comprehensive test coverage

Quick Start
-----------

[](#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

Questions?
----------

[](#questions)

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

[](#join-our-slack-community)

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

[](#contributing)

1. [Download PHP](https://www.php.net/manual/en/install.php) and [Composer](https://getcomposer.org/download/)
2. `php composer.phar update` to install dependencies
3. `bin/test` to run tests (this script calls `./vendor/bin/phpunit --verbose test`)

Releasing
---------

[](#releasing)

Releases are semi-automated via GitHub Actions. When a PR with the `release` and a version bump label is merged to `master`, the release workflow is triggered.

You'll need an approval from a PostHog engineer. If you're an employee, you can see the request in the [\#approvals-client-libraries](https://app.slack.com/client/TSS5W8YQZ/C0A3UEVDDNF) channel.

### Release Process

[](#release-process)

1. **Create your PR** with the changes you want to release
2. **Add the `release` label** to the PR
3. **Add a version bump label** that should be either `bump-patch`, `bump-minor` or `bump-major`
4. **Merge the PR** to `master`

Once merged, the following happens automatically:

1. A Slack notification is sent to the client libraries channel requesting approval
2. A maintainer approves the release in the GitHub `Release` environment
3. The version is bumped in `lib/PostHog.php` and `composer.json` based on the version label (`patch`, `minor`, or `major`, extracted from the label)
4. The `CHANGELOG.md` is updated with a link to the full changelog
5. Changes are committed and pushed to `master`
6. A git tag is created (e.g., `v1.8.0`)
7. A GitHub release is created with the changelog content
8. Slack is notified of the successful release

Releases are installed directly from GitHub.

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community38

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor5

5 contributors hold 50%+ of commits

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

Every ~46 days

Recently: every ~26 days

Total

39

Last Release

60d ago

Major Versions

2.1.1 → 3.0.02022-08-15

3.7.3 → 4.0.02026-01-09

PHP version history (3 changes)2.0.0PHP &gt;=7.1

3.0.0PHP &gt;=8.0

4.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c8665c5fd9aecc249ec2eeaf505e9b4f8733e4a9f66275decd86979b68586fd?d=identicon)[timgl](/maintainers/timgl)

---

Top Contributors

[![EDsCODE](https://avatars.githubusercontent.com/u/13127476?v=4)](https://github.com/EDsCODE "EDsCODE (44 commits)")[![yakkomajuri](https://avatars.githubusercontent.com/u/38760734?v=4)](https://github.com/yakkomajuri "yakkomajuri (25 commits)")[![neilkakkar](https://avatars.githubusercontent.com/u/7115141?v=4)](https://github.com/neilkakkar "neilkakkar (23 commits)")[![joesaunderson](https://avatars.githubusercontent.com/u/11272509?v=4)](https://github.com/joesaunderson "joesaunderson (18 commits)")[![imhmdb](https://avatars.githubusercontent.com/u/34659256?v=4)](https://github.com/imhmdb "imhmdb (16 commits)")[![mariusandra](https://avatars.githubusercontent.com/u/53387?v=4)](https://github.com/mariusandra "mariusandra (15 commits)")[![haacked](https://avatars.githubusercontent.com/u/19977?v=4)](https://github.com/haacked "haacked (11 commits)")[![alexkim205](https://avatars.githubusercontent.com/u/13460330?v=4)](https://github.com/alexkim205 "alexkim205 (11 commits)")[![Twixes](https://avatars.githubusercontent.com/u/4550621?v=4)](https://github.com/Twixes "Twixes (10 commits)")[![macobo](https://avatars.githubusercontent.com/u/148820?v=4)](https://github.com/macobo "macobo (10 commits)")[![dmarticus](https://avatars.githubusercontent.com/u/4853149?v=4)](https://github.com/dmarticus "dmarticus (7 commits)")[![danielbachhuber](https://avatars.githubusercontent.com/u/36432?v=4)](https://github.com/danielbachhuber "danielbachhuber (5 commits)")[![dustinbyrne](https://avatars.githubusercontent.com/u/8737782?v=4)](https://github.com/dustinbyrne "dustinbyrne (4 commits)")[![releaser-posthog-php[bot]](https://avatars.githubusercontent.com/in/2618603?v=4)](https://github.com/releaser-posthog-php[bot] "releaser-posthog-php[bot] (4 commits)")[![cat-ph](https://avatars.githubusercontent.com/u/268578347?v=4)](https://github.com/cat-ph "cat-ph (3 commits)")[![wundo](https://avatars.githubusercontent.com/u/113942?v=4)](https://github.com/wundo "wundo (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")[![marandaneto](https://avatars.githubusercontent.com/u/5731772?v=4)](https://github.com/marandaneto "marandaneto (3 commits)")[![vdekrijger](https://avatars.githubusercontent.com/u/66254686?v=4)](https://github.com/vdekrijger "vdekrijger (2 commits)")[![andyzzhao](https://avatars.githubusercontent.com/u/34008309?v=4)](https://github.com/andyzzhao "andyzzhao (2 commits)")

---

Tags

posthog

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/posthog-posthog-php/health.svg)

```
[![Health](https://phpackages.com/badges/posthog-posthog-php/health.svg)](https://phpackages.com/packages/posthog-posthog-php)
```

###  Alternatives

[symfony/scheduler

Provides scheduling through Symfony Messenger

8910.8M52](/packages/symfony-scheduler)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[symfony/ai-agent

PHP library for building agentic applications.

30536.7k44](/packages/symfony-ai-agent)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)

PHPackages © 2026

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