Skip to content

Commit cfafebc

Browse files
haackedCopilot
andauthored
feat(flags): Implement local evaluation of flag dependencies (#84)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3b4bfb6 commit cfafebc

File tree

11 files changed

+1859
-114
lines changed

11 files changed

+1859
-114
lines changed

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# PostHog API Configuration
2+
# Copy this file to .env and update with your actual values
3+
4+
# Your project API key (found on the /setup page in PostHog)
5+
POSTHOG_PROJECT_API_KEY=phc_your_project_api_key_here
6+
7+
# Your personal API key (for local evaluation and other advanced features)
8+
POSTHOG_PERSONAL_API_KEY=phx_your_personal_api_key_here
9+
10+
# PostHog host URL (remove this line if using posthog.com)
11+
POSTHOG_HOST=https://app.posthog.com

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ test/posthog.log
88
.phpunit.result.cache
99
clover.xml
1010
xdebug.log
11-
.DS_Store
11+
.DS_Store
12+
.env

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ Please see the main [PostHog docs](https://posthog.com/docs).
44

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

7+
## Features
8+
9+
- ✅ Event capture and user identification
10+
- ✅ Feature flag local evaluation
11+
-**Feature flag dependencies** (new!) - Create conditional flags based on other flags
12+
- ✅ Multivariate flags and payloads
13+
- ✅ Group analytics
14+
- ✅ Comprehensive test coverage
15+
16+
## Quick Start
17+
18+
1. Copy `.env.example` to `.env` and add your PostHog credentials
19+
2. Run `php example.php` to see interactive examples of all features
20+
721
## Questions?
822

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

11-
1225
## Contributing
1326

1427
1. [Download PHP](https://www.php.net/manual/en/install.php) and [Composer](https://getcomposer.org/download/)

bin/fmt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Source helper functions
5+
source "$(dirname "$0")/helpers/_utils.sh"
6+
set_source_and_root_dir
7+
8+
# Format PHP files using PHPCBF (PHP Code Beautifier and Fixer)
9+
echo "Formatting PHP files..."
10+
11+
# Check if vendor/bin/phpcbf exists
12+
if [ ! -f "./vendor/bin/phpcbf" ]; then
13+
fatal "PHPCBF not found. Please run 'composer install' first."
14+
fi
15+
16+
# Run PHPCBF on all PHP files in lib/ and test/ directories
17+
echo "Running PHPCBF on lib/ and test/ directories..."
18+
./vendor/bin/phpcbf --standard=phpcs.xml lib/ test/ || {
19+
# PHPCBF returns exit code 1 when it fixes files, which is expected behavior
20+
# Only fail if it's a different error (exit code 2 or higher)
21+
exit_code=$?
22+
if [ $exit_code -gt 1 ]; then
23+
fatal "PHPCBF failed with exit code $exit_code"
24+
fi
25+
echo "PHPCBF finished fixing files (exit code $exit_code is expected when fixes are made)"
26+
}
27+
28+
# Also format the example.php file
29+
echo "Running PHPCBF on example.php..."
30+
./vendor/bin/phpcbf --standard=phpcs.xml example.php || {
31+
exit_code=$?
32+
if [ $exit_code -gt 1 ]; then
33+
fatal "PHPCBF failed on example.php with exit code $exit_code"
34+
fi
35+
}
36+
37+
echo "PHP formatting complete!"

0 commit comments

Comments
 (0)