feature-flags-php
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePostHog feature flags for PHP
面向PHP应用的PostHog功能开关
This skill helps you add PostHog feature flags to PHP applications.
本技能可帮助你在PHP应用中集成PostHog功能开关。
Reference files
参考文件
- - Php feature flags installation - docs
references/php.md - - Adding feature flag code - docs
references/adding-feature-flag-code.md - - Feature flag best practices - docs
references/best-practices.md
Consult the documentation for API details and framework-specific patterns.
- - PHP功能开关安装文档
references/php.md - - 添加功能开关代码文档
references/adding-feature-flag-code.md - - 功能开关最佳实践文档
references/best-practices.md
如需了解API详情和特定框架的实现模式,请查阅相关文档。
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密钥,切勿硬编码。
- 最小改动:在现有逻辑旁添加功能开关代码,不要替换或重构现有代码。
- 优先布尔型开关:默认使用布尔型开关检查,除非用户明确要求多变量开关。
- 尽可能服务端处理:优先选择服务端开关评估,以避免UI闪烁问题。
PostHog MCP tools
PostHog MCP工具
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.
检查是否已连接PostHog MCP服务器。如果已连接,查找与功能开关管理相关的工具(创建、列出、更新、删除开关)。使用这些工具直接在PostHog中管理开关,无需用户在控制面板中手动操作。
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
- 请注意,composer安装完成后,源代码会存放在vendor目录中
- posthog/posthog-php是PHP SDK的包名
- 在添加新文件前,检查composer.json中的现有依赖和自动加载配置
- PHP SDK采用静态方法(PostHog::capture、PostHog::identify),只需通过PostHog::init()初始化一次
- PHP SDK方法接受包含'distinctId'、'event'、'properties'键的关联数组,而非位置参数