Quickstart by stack
PHP Quickstart
Install the PHP SDK with Composer, evaluate a flag with context, and keep failure modes safe with defaults.
Prerequisites
- A PHP application with Composer available.
- A server key stored in application configuration.
- A flag key you can test in a non-production environment.
Install
bash
composer require zenmanage/zenmanage
Initialize and evaluate
php
use Zenmanage\Config\ConfigBuilder;
use Zenmanage\Flags\Context\Attribute;
use Zenmanage\Flags\Context\Context;
use Zenmanage\Zenmanage;
$zenmanage = new Zenmanage(
ConfigBuilder::create()
->withEnvironmentToken($_ENV['ZENMANAGE_SERVER_KEY'])
->build()
);
$context = new Context(
type: 'user',
name: 'Jane Doe',
identifier: 'usr_123',
attributes: [new Attribute('plan', ['enterprise'])]
);
$flag = $zenmanage->flags()
->withContext($context)
->single('new-checkout', false);
if ($flag->isEnabled()) {
// render new experience
}
Error-handling pattern
php
try {
$timeout = $zenmanage->flags()->single('api-timeout-ms', 5000)->asNumber();
} catch (\Throwable $e) {
$timeout = 5000;
}
Context and defaults
The PHP SDK supports context-aware evaluation, local rule evaluation, and both inline defaults and default collections. Start with inline defaults for the first integration, then move to collections when multiple flags share the same failure posture.
Next step
Take the next integration step in your own stack.
Start with the quickstart that matches your runtime, then return to the reference pages when you need exact request and payload details.