zenmanage / zenmanage-php
Zenmanage API SDK for PHP
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^6.3|^7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2024-11-22 22:04:24 UTC
README
This library helps with integrating Zenmanage into PHP applications.
Installation
This library can be installed via Composer:
composer require zenmanage/zenmanage-php
Configuration
The only required configuration is the Environment Token. You can get your Environment Token via the Project settings in your Zenmanage account.
Configuration values can be set when creating a new API client or via environment variables. The environment takes precedence over values provided during the initialization process.
Configuration via environment variables
ZENMANAGE_ENVIRONMENT_TOKEN=tok_sample
Configuration during initialization
use \Zenmanage\Client; $client = new Client::config(['environment_token' => 'tok_sample'])->connect();
Context
When retrieving values for feature flags a context can be provided that can change the value based on unique attributes of the context.
use \Zenmanage\Client; use \Zenmanage\Flags\Request\Entities\Context\Attribute; use \Zenmanage\Flags\Request\Entities\Context\Context; use \Zenmanage\Flags\Request\Entities\Context\Value; $context = new Context('user', 'John Doe', 'john-doe', [ new Attribute('key', [ new Value('value'), ]), ]); $client = Client::config() ->withContext($context) ->connect(); $results = $client->all(); $result = $client->get('flag-key')->getValue();
Usage
Before retrieving a feature flag, create a new client. If you configured your environment token key via environment variables there's nothing to add. Otherwise, see the example above.
use \Zenmanage\Client; $client = new Client();
Retrieving Flags
All Flags
$results = $client->all(); foreach ($results as $results) { $key = $result->key; $name = $result->name; $type = $result->type; $value = $result->value }
Single Flag
$result = $client->flag('flag-key'); $key = $result->key; $name = $result->name; $type = $result->type; $value = $result->value
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/zenmanage/zenmanage-php. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The library is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Zenmanage’s code bases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
What is Zenmanage?
Zenmanage allows you to control how feature flags are configured in your application giving you better flexibility to deploy code and release when you are ready.
Zenmanage was started in 2023 as an alternative to highly complex feature flag tools. Learn more about us.