amplitude / experiment-php-server
PHP Amplitude 实验服务器 SDK
1.2.1
2024-09-17 07:07 UTC
Requires
- php: ^7.4 || ^8
- ext-json: *
- guzzlehttp/guzzle: ^7
- psr/cache: ^1 || ^2 || ^3
- psr/log: ^1 || ^2 || ^3
- symfony/cache: ^5 || ^6 || ^7
Requires (Dev)
- phpstan/phpstan: ^1
- phpunit/phpunit: 9.*
Suggests
- monolog/monolog: Allows more advanced logging of the application flow
- dev-main
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.2
- 0.1.1
- v0.1.0
- dev-composer-cache-versions
- dev-configure-assign-cache
- dev-event-from-array
- dev-remove-api-key-log
- dev-v1-release
- dev-assignment-timestamp
- dev-tracking-provider
- dev-async-flush
- dev-custom-enhancement
- dev-update-test-yml
This package is auto-updated.
Last update: 2024-09-17 07:07:44 UTC
README
实验 PHP SDK
Amplitude PHP 服务器 SDK 用于实验。
安装
composer require amplitude/experiment-php-server
远程评估快速入门
<?php // (1) Initialize the experiment client $experiment = new \AmplitudeExperiment\Experiment(); $client = $experiment->initializeRemote('<DEPLOYMENT_KEY>') // (2) Fetch variants for a user $user = \AmplitudeExperiment\User::builder() ->deviceId('abcdefg') ->userId('user@company.com') ->userProperties(['premium' => True]) ->build(); $variants = $client->fetch($user); // (3) Access a flag's variant $variant = $variants['FLAG_KEY'] ?? null; if ($variant) { if ($variant->value == 'on') { // Flag is on } else { // Flag is off } }
本地评估快速入门
<?php // (1) Initialize the experiment client $experiment = new \AmplitudeExperiment\Experiment(); $client = $experiment->initializeLocal('<DEPLOYMENT_KEY>'); // (2) Fetch latest flag configurations for the local evaluation client. $client->refreshFlagConfigs(); // (3) Evaluate a user. $user = \AmplitudeExperiment\User::builder() ->deviceId('abcdefg') ->userId('user@company.com') ->userProperties(['premium' => true]) ->build(); // Evaluate all flag variants $allVariants = $client->evaluate($user); // Evaluate a specific subset of flag variants $specificVariants = $client->evaluate($user, [ 'my-local-flag-1', 'my-local-flag-2', ]); // (4) Access a flag's variant $variant = $allVariants['FLAG_KEY'] ?? null; if ($variant) { if ($variant->value == 'on') { // Flag is on } else { // Flag is off } }
更多信息
请访问我们的 开发者中心 了解如何使用 SDK 的更多说明。
需要帮助?
如果您对我们的 SDK 有任何问题或问题,请随时 在 GitHub 上创建一个问题 或在 Amplitude 帮助 上提交请求。