Download the PHP package eppo/php-sdk without Composer
On this page you can find all versions of the php package eppo/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package php-sdk
Short Description Eppo PHP SDK
License MIT
Homepage https://github.com/Eppo-exp/php-sdk
Informations about the package php-sdk
Eppo PHP SDK
Eppo is a modular flagging and experimentation analysis tool. Eppo's PHP SDK is built to make assignments in multi-user server side contexts, compatible with PHP 7.3 and above. Before proceeding you'll need an Eppo account.
Features
- Feature gates
- Kill switches
- Progressive rollouts
- A/B/n experiments
- Mutually exclusive experiments (Layers)
- Dynamic configuration
- Multi-armed Contextual Bandits
Installation
Quick start
Begin by initializing a singleton instance of Eppo's client. Once initialized, the client can be used to make assignments anywhere in your app.
Initialize once
Assign anywhere
Select a Bandit Action
This SDK supports Multi-armed Contextual Bandits.
Assignment functions
Every Eppo flag has a return type that is set once on creation in the dashboard. Once a flag is created, assignments in code should be made using the corresponding typed function:
Each function has the same signature, but returns the type in the function name. For booleans use getBooleanAssignment
, which has the following signature:
Initialization options
The init
function accepts the following optional configuration arguments.
Option | Type | Description | Default |
---|---|---|---|
cache |
Instance of PSD-16 SimpleInterface | Cache used to store flag configuration. If not passed, FileSystem cache will be used | null |
assignmentLogger |
AssignmentLogger/IBanditLogger | Logs assignment events back to data warehoouse | null |
httpClient |
ClientInterface | For making HTTP requests. If not passed, Discovery will attempt to autoload an applicable pacakge | null |
requestFactory |
RequestFactoryInterface | Instance of PSR-17 Factory. If not passed, Discovery will be used to find a suitable implementation | null |
Assignment logger
To use the Eppo SDK for experiments that require analysis, pass in an implementation of the LoggerInterface
to the init
function on SDK initialization. The SDK invokes the callback to capture assignment data whenever a variation is assigned. The assignment data is needed in the warehouse to perform analysis.
The code below illustrates an example implementation of a logging callback using Segment, but you can use any system you'd like. The only requirement is that the SDK receives a logAssignment
callback function. Here we define an implementation of the Eppo AssignmentLogger
interface containing a single function named logAssignment
:
Bandit Action Logging
When using Bandits, a different logging method is called. Your logging class must implement IBanditLogger
instead of LoggerInterface
.
Background Polling
To make the experience of using the library faster, there is an option to start a background polling for randomization params. This 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:
after this, run this script by:
This will start an indefinite process of polling the Eppo-api.
Troubleshooting
HTTP
This package uses the php-http/discovery
package to automatically locate implementations of the various HTTP related
PSR interfaces (ex: ClientInterface
, RequstFactory
, etc.). If your project does not depend on any library which can
fulfill this need, you may see an exception such as follows.
Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy.
To solve this, simply require a suitable package, such as guzzle
composer require guzzlehttp/guzzle:^7.0
Philosophy
Eppo's SDKs are built for simplicity, speed and reliability. Flag configurations are compressed and distributed over a global CDN (Fastly), typically reaching your servers in under 15ms. Server SDKs continue polling Eppo’s API at 30-second intervals. Configurations are then cached locally, ensuring that each assignment is made instantly. Evaluation logic within each SDK consists of a few lines of simple numeric and string comparisons. The typed functions listed above are all developers need to understand, abstracting away the complexity of the Eppo's underlying (and expanding) feature set.
All versions of php-sdk with dependencies
ext-json Version *
psr/simple-cache Version 3.*
shrikeh/teapot Version ^2.3
composer/semver Version ^3.4
php-http/discovery Version ^1.17
webclient/ext-redirect Version ^2.0
symfony/cache Version ^6.4