PHP code example of absurge / php

1. Go to this page and download the library: Download absurge/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/ */

    

absurge / php example snippets


use ABsurge\ABsurge;

$absurge = new ABsurge(
    publishableKey: 'pk_...',
    baseUrl: 'https://your-app.example/api/v1',
    environment: 'production',
);

// Evaluate flags and experiments for a user
$result = $absurge->evaluate('user-123', ['plan' => 'pro']);

// Check a single flag
$enabled = $absurge->isEnabled('new-checkout', 'user-123');

// Get experiment assignment
$experiment = $absurge->getExperiment('pricing-test', 'user-123');

// Track events
$absurge->trackExposure('pricing-test', 'user-123');
$absurge->trackConversion('pricing-test', 'user-123', 'purchase', 49.0);
bash
composer