Feature Flags Php
PostHogOfficialCreated by PostHog
- Skill
- Tool integration
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides guidance and best practices for implementing PostHog feature flags within PHP applications. It covers the integration of the PostHog PHP SDK, emphasizing server-side evaluation to prevent UI flickering and ensuring consistent flag behavior. The skill includes instructions on managing flags, using environment variables for configuration, and adhering to clean coding standards by minimizing flag dispersion throughout the codebase.
What it does
- Provides patterns for integrating PostHog feature flags in PHP environments.
- Outlines best practices for flag naming, targeting, and lifecycle management.
- Explains how to use the PostHog PHP SDK for server-side flag evaluation.
- Offers guidance on using environment variables for secure API key management.
- Suggests architectural patterns to keep feature flag logic clean and maintainable.
When to use it
- When you need to implement feature toggles in a PHP-based backend.
- When you want to perform server-side feature flag evaluation to improve performance.
- When you need to standardize how feature flags are accessed across your PHP application.
- When you are setting up new experiments or phased feature releases in a PHP project.
Advantages
- Reduces UI flicker by enabling server-side flag evaluation.
- Promotes clean code through centralized flag handling.
- Ensures secure configuration via environment variables.
- Provides clear conventions for naming and organizing feature flags.
Usage examples
- “How do I initialize the PostHog PHP SDK for feature flags?”
- The agent will explain the use of PostHog::init() and emphasize that it should be called once, using environment variables for the API key.
- “What is the best way to check a feature flag in my PHP controller?”
- The agent will recommend wrapping the flag check in a dedicated function or method to keep the controller logic clean and maintainable.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/posthog/feature-flags-php/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip feature-flags-php.zip -d .agents/skills
Documentation by PostHog
PostHog feature flags for PHP
This skill helps you add PostHog feature flags to PHP applications.
Reference files
references/php.md- Php feature flags installation - docsreferences/adding-feature-flag-code.md- Adding feature flag code - docsreferences/best-practices.md- Feature flag best practices - docs
Consult the documentation for API details and framework-specific patterns.
Key principles
Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
Minimal changes: Add feature flag code alongside existing logic. Don't replace or restructure existing code.
Boolean flags first: Default to boolean flag checks unless the user specifically asks for multivariate flags.
Server-side when possible: Prefer server-side flag evaluation to avoid UI flicker.
PostHog MCP tools
Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.
Framework guidelines
Remember that source code is available in the vendor directory after composer install
posthog/posthog-php is the PHP SDK package name
Check composer.json for existing dependencies and autoload configuration before adding new files
The PHP SDK uses static methods (PostHog::capture, PostHog::identify) - initialize once with PostHog::init()
PHP SDK methods take associative arrays with 'distinctId', 'event', 'properties' keys - not positional arguments
Files
- ATTRIBUTION.mdAdded by AutoGineer951 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md1.7 KiB
- references/adding-feature-flag-code.md108.7 KiB
- references/best-practices.md7.9 KiB
- references/php.md4.6 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/posthog/feature-flags/skills/php · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- PostHog/skills
AutoGineer is not affiliated with or endorsed by PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download feature-flags-php.zip