An SDK for the Flags application written in PHP
composer require flags/php-sdk
- Obtain an auth token
$user = new \Flags\User($email, $password);
$authorizer = new \Flags\Authorizer();
$authorizer->authorize($user);
The authorizer will return the same user instance with a fresh token.
- Define the flag you want to evaluate
$flag = new \Flags\Flag($flagIdentifier);
Here, $flagIdentifier
is a string, corresponding to the flag's token.
- Evaluate the flag
$evaluator = new \Flags\Evaluator();
$response = $evaluator->evaluate($flag, $user, $applicationUser);
$response->getResult();
Here, $applicationUser
is a string representing the application user's identifier.
You can see a working example by running php examples/demo.php
. You will need to provide valid user information in examples/demo.json
.
-
Clone this repo.
-
Run
composer update
from the root directory. -
Check everything is working by running the tests via
vendor/bin/phpunit