eppo / php-sdk
Eppo PHP SDK
Installs: 7 919
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 6
Forks: 1
Open Issues: 1
Requires
- php: ^7.3.31 || ^8.0
- ext-json: *
- sarahman/simple-filesystem-cache: ^1.0
- shrikeh/teapot: ^2.3
Requires (Dev)
- ext-pcntl: *
- ext-posix: *
- google/cloud-storage: ^1.30
- phpunit/phpunit: ^9.6
- dev-main
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- dev-leoromanovsky-patch-1
- dev-lr/ff-953/try
- dev-catchup-upstream-121
- dev-lr/ff-1018/one-request
- dev-lr/ff-888/no-guzzle
- dev-lr/ff-962/php-sdk-name
- dev-docs-link-fix
- dev-pavel/upgrade-composer-version
- dev-pavel/improve-request-timeout
- dev-pavel/ANA-182-php-sdk
This package is auto-updated.
Last update: 2024-04-16 18:13:27 UTC
README
EppoClient is a client sdk for eppo.cloud
randomization API.
It is used to retrieve the experiments data and put it to in-memory cache, and then get assignments information.
Getting Started
Refer to our SDK documentation for how to install and use the SDK.
Supported PHP Versions
This version of the SDK is compatible with PHP 7.3 and above.
Install
composer require eppo/php-sdk
Example
<?php use Eppo\EppoClient; require __DIR__ . '/vendor/autoload.php'; $eppoClient = EppoClient::init( "<your_api_key>", "<base_url>", // optional, default https://fscdn.eppo.cloud/api $assignmentLogger, // optional, must be an instance of Eppo\Logger\LoggerInterface $cache // optional, must be an instance of PSR-16 CacheInterface. If not passed, FileSystem cache will be used ); $subjectAttributes = []; $assignment = $eppoClient->getAssignment('subject-1', 'experiment_5', $subjectAttributes); if ($assignment === 'control') { // do something }
To make the experience of using the library faster, there is an option to start a background polling for randomization params. This way background job will start calling the Eppo api, updating the config in the cache.
For this, create a file, e.g. eppo-poller.php
with the contents:
$eppoClient = EppoClient::init( "<your_api_key>", "<base_url>", // optional, default https://fscdn.eppo.cloud/api $assignmentLogger, // optional, must be an instance of Eppo\LoggerInterface $cache // optional, must be an instance of PSD-16 SimpleInterface. If not passed, FileSystem cache will be used ); $eppoClient->startPolling();
after this, run this script by:
php eppo-poller.php
This will start an indefinite process of polling the Eppo-api.