1. Go to this page and download the library: Download guidelytech/guidely-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use GuidelyTech\Flags\Sticky\StickyBucketServiceInterface;
final class RedisStickyBuckets implements StickyBucketServiceInterface
{
public function __construct(private \Redis $redis) {}
public function getAssignments(string $docKey): ?array
{
$raw = $this->redis->get("sticky:$docKey");
return $raw === false ? null : json_decode($raw, true);
}
public function saveAssignments(string $docKey, array $assignments): void
{
$this->redis->set("sticky:$docKey", json_encode($assignments));
}
}
$flags = new GuidelyFlags([
'overrides' => ['new-checkout' => true, 'upload-limit-mb' => 50],
'overrideBehaviour' => 'localOnly', // no network, no usage reports
]);
$flags->setOverrides(['new-checkout' => false]); // change them mid-test
$flags = new GuidelyFlags(['sdkKey' => 'pk_…', 'remoteEval' => true]);
$flags->isEnabled('new-checkout', ['id' => 'u_123']); // POST /api/v1/sdk/flags/evaluate