zenmanage/zenmanage-php

Zenmanage API SDK for PHP

2.0.1 2024-04-25 18:40 UTC

This package is auto-updated.

Last update: 2024-04-25 18:41:46 UTC


README

Build Status

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 settings a context can be provided that can change the value based on unique attributes of the context.

use \Zenmanage\Client;
use \Zenmanage\Settings\Request\Entities\Context\Attribute;
use \Zenmanage\Settings\Request\Entities\Context\Context;
use \Zenmanage\Settings\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('setting-key')->getValue();

Usage

Before retrieving a setting or 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 Settings

All Settings

$results = $client->all();

foreach ($results as $results) {
    $key = $result->key;
    $name = $result->name;
    $type = $result->type;
    $value = $result->value
}

Single Setting

$result = $client->setting('setting-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 Software’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 which features and settings are enabled in your application giving you better flexibility to deploy code and release features.

Zenmanage Software was started in 2023 as an alternative to highly complex feature flag tools. Learn more about us.