1. Go to this page and download the library: Download eppo/php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eppo / php-sdk example snippets
use Eppo\EppoClient;
nit(
'<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 SimpleCache\CacheInterface. If not passed, FileSystem cache will be used
$httpClient // optional, must be an instance of PSR-18 ClientInterface. If not passed, Discovery will be used to find a suitable implementation
$requestFactory // optional, must be an instance of PSR-17 Factory. If not passed, Discovery will be used to find a suitable implementation
);
use Eppo\Logger\LoggerInterface;
use Eppo\Logger\AssignmentEvent;
use Eppo\Logger\LoggerInterface;
class SegmentLogger implements LoggerInterface
{
public function logAssignment(AssignmentEvent $assignmentEvent): void
{
Segment::track([
'event' => 'Flag Assignment for ' . $assignmentEvent->featureFlag,
'userId' => $assignmentEvent->subject,
'properties' => $assignmentEvent->toArray()
]);
}
}
use Eppo\Logger\AssignmentEvent;
use Eppo\Logger\BanditActionEvent;
use Eppo\Logger\IBanditLogger;
class SegmentLogger implements IBanditLogger
{
public function logAssignment(AssignmentEvent $assignmentEvent): void
{
Segment::track([
'event' => 'Flag Assignment for ' . $assignmentEvent->featureFlag,
'userId' => $assignmentEvent->subject,
'properties' => $assignmentEvent->toArray()
]);
}
public function logBanditAction(BanditActionEvent $banditActionEvent): void
{
Segment::track([
'event' => 'Bandit Action Selected',
'userId' => $banditActionEvent->subjectKey,
'properties' => $banditActionEvent->toArray()
]);
}
}
$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 PSR-16 SimpleInterface. If not passed, FileSystem cache will be used
$httpClient // optional, must be an instance of PSR-18 ClientInterface. If not passed, Discovery will be used to find a suitable implementation
$requestFactory // optional, must be an instance of PSR-17 Factory. If not passed, Discovery will be used to find a suitable implementation
);
$eppoClient->startPolling();
shell
composer
shell
php eppo-poller.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.