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
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# PostHog API Configuration
# Copy this file to .env and update with your actual values

# Your project API key (found on the /setup page in PostHog)
POSTHOG_PROJECT_API_KEY=phc_your_project_api_key_here

# Your personal API key (for local evaluation and other advanced features)
POSTHOG_PERSONAL_API_KEY=phx_your_personal_api_key_here

# PostHog host URL (remove this line if using posthog.com)
POSTHOG_HOST=https://app.posthog.com
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test/posthog.log
.phpunit.result.cache
clover.xml
xdebug.log
.DS_Store
.DS_Store
.env
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ Please see the main [PostHog docs](https://posthog.com/docs).

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

## 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

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

## Questions?

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


## Contributing

1. [Download PHP](https://www.php.net/manual/en/install.php) and [Composer](https://getcomposer.org/download/)
Expand Down
37 changes: 37 additions & 0 deletions bin/fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e

# Source helper functions
source "$(dirname "$0")/helpers/_utils.sh"
set_source_and_root_dir

# Format PHP files using PHPCBF (PHP Code Beautifier and Fixer)
echo "Formatting PHP files..."

# Check if vendor/bin/phpcbf exists
if [ ! -f "./vendor/bin/phpcbf" ]; then
fatal "PHPCBF not found. Please run 'composer install' first."
fi

# Run PHPCBF on all PHP files in lib/ and test/ directories
echo "Running PHPCBF on lib/ and test/ directories..."
./vendor/bin/phpcbf --standard=phpcs.xml lib/ test/ || {
# PHPCBF returns exit code 1 when it fixes files, which is expected behavior
# Only fail if it's a different error (exit code 2 or higher)
exit_code=$?
if [ $exit_code -gt 1 ]; then
fatal "PHPCBF failed with exit code $exit_code"
fi
echo "PHPCBF finished fixing files (exit code $exit_code is expected when fixes are made)"
}

# Also format the example.php file
echo "Running PHPCBF on example.php..."
./vendor/bin/phpcbf --standard=phpcs.xml example.php || {
exit_code=$?
if [ $exit_code -gt 1 ]; then
fatal "PHPCBF failed on example.php with exit code $exit_code"
fi
}

echo "PHP formatting complete!"
Loading