Skip to content

PHP SDK

PHPv0.1.3
  • PHP 8.1+
  • PDO extension (for SQLite cache)
  • cURL extension
  • Redis extension (optional)
Terminal window
composer require flags-gg/flags-php
<?php
require_once 'vendor/autoload.php';
use FlagsGG\Client;
$client = new Client();
$client->setAuth(
projectId: 'your-project-id',
agentId: 'your-agent-id',
environmentId: 'your-environment-id'
);
// Check a flag
if ($client->is('new-feature')->enabled()) {
echo "Feature is enabled!";
}
// Or use the shorthand
if ($client->isEnabled('new-feature')) {
echo "Feature is enabled!";
}
// List all flags
$flags = $client->list();
foreach ($flags as $flag) {
echo $flag->details->name . ': ' . ($flag->enabled ? 'enabled' : 'disabled') . "\n";
}