Varypilot/ DOCUMENTATION
Open app ↗

Integrations

PHP SDK

Use the PHP 7.0+ client with server-side assignment and a persistent cache.

Download and configure

Download varypilot.php and require it in your application. The PHP SDK supports PHP 7.0 and later. Configure your actual project key, environment, endpoint, stable visitor ID, current URL, server credential and analytics consent.

Client structure

php
<?php
require_once __DIR__ . '/varypilot.php';
$ab = new ABPlatform\Client(array(
  'projectKey' => $publicProjectKey,
  'environment' => $environmentName,
  'endpoint' => 'https://varypilot-edge-api.silva-pires-ricardo86.workers.dev',
  'serverKey' => getenv('VARYPILOT_SERVER_KEY'),
  'visitorId' => $stableVisitorId,
  'url' => $currentUrl,
  'cacheDir' => $privateWritableCacheDirectory,
  'consent' => $analyticsConsentGranted
));
$ab->init();
$variant = $ab->getVariant($experimentKey, $controlVariantKey);
// Render first, then record exposure.
$ab->trackExposure($experimentKey, $variant);
$ab->flush();

Cache and delivery

Use a writable, private cache directory. Keep the server credential outside public files and source control. Verify behavior for network errors and unavailable configuration before deploying to production.