flipt-io / flipt
Flipt Server SDK
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7
- psr/log: ^1.0|^2.0|^3.0
Requires (Dev)
- phpunit/php-code-coverage: ^10
- phpunit/phpunit: ^10
README
This directory contains the PHP source code for the Flipt server-side client.
Note
If you are on the https://github.com/flipt-io/flipt-php repository, this is a mirror of the source code. Please file issues and pull requests against the flipt-io/flipt-server-sdks repository.
Requirements
- PHP 8.0 or higher
- Composer
Documentation
API documentation is available at https://www.flipt.io/docs/reference/overview.
Installation
composer install flipt-io/flipt
Usage
In your PHP code you can import this client and use it as so:
<?php use Flipt\Client\FliptClient; $fliptClient = new FliptClient(); $result = $fliptClient->variant('flag1', ['fizz' => 'buzz'], 'entity');
There is a more detailed example in the tests directory.
Setting HTTP Headers
You can set custom HTTP headers for the client by using the withHeaders
method.
$fliptClient = new FliptClient(); $fliptClient->withHeaders(['X-Custom-Header' => 'Custom-Value']);
Flipt V2 Environment Support
Flipt V2 introduces the concept of environments. This client supports evaluation of flags in a specific environment by using the X-Flipt-Environment
header.
$fliptClient = new FliptClient(); $fliptClient->withHeaders(['X-Flipt-Environment' => 'production']);
Thanks 🎉
Thanks to legoheld for the initial implementation of this client.