flags / php-sdk
An SDK for the Flags application written in PHP.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/flags/php-sdk
Requires
- php: ~7.1.0
- ext-curl: *
- cache/filesystem-adapter: *
Requires (Dev)
This package is not auto-updated.
Last update: 2020-01-18 05:34:11 UTC
README
An SDK for the Flags application written in PHP
Installation
composer require flags/php-sdk
Usage
- 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.
Demo
You can see a working example by running php examples/demo.php. You will need to provide valid user information in examples/demo.json.
Contributing
-
Clone this repo.
-
Run
composer updatefrom the root directory. -
Check everything is working by running the tests via
vendor/bin/phpunit