PHP code example of checkmango / php-sdk

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

    

checkmango / php-sdk example snippets


$client = new Checkmango\Client();
$client->authenticate('your_api_token');

$organizations = $client->organizations()->list();
$organization = $client->organizations($organizationId);
$config = $organization->config();
$experiment = $organization->experiments()->show('EXPERIMENT_KEY');

// Enroll the participant and track an impression for the selected variant.
$organization->ingest()->store('EXPERIMENT_KEY', 'PARTICIPANT_KEY', 'VARIANT_KEY');

// Track a conversion, optionally supplying a revenue value.
$organization->ingest()->store('EXPERIMENT_KEY', 'PARTICIPANT_KEY', 'VARIANT_KEY', 'EVENT_KEY');
$organization->ingest()->store('EXPERIMENT_KEY', 'PARTICIPANT_KEY', 'VARIANT_KEY', 'REVENUE_EVENT', 29.95);

$organization = $client->organizations($organizationId)->show();
$organization = $client->organizations()->show($organizationId);
$currentOrganization = $client->currentOrganization();
$user = $client->user();
$health = $client->health(); // Does not 

$organization = $client->organizations($organizationId);
$organization->events()->create('PURCHASE', ['type' => 'count', 'is_revenue' => true]);
$organization->experiments()->create('CHECKOUT', ['event_key' => 'PURCHASE']);
$organization->experiments()->variants('CHECKOUT')->create(['key' => 'CONTROL', 'control' => true]);
$organization->experiments()->variants('CHECKOUT')->create(['key' => 'BLUE', 'control' => false]);
$organization->experiments()->start('CHECKOUT');
$statistics = $organization->experiments()->variants('CHECKOUT')->statistics('BLUE', ['event_key' => 'PURCHASE']);
$organization->experiments()->stop('CHECKOUT');

$features = $client->organizations($organizationId)->features();
$features->create('NEW_CHECKOUT', ['enabled' => true, 'value' => 'blue', 'format' => 'text']);
$feature = $features->show('NEW_CHECKOUT');
$features->update('NEW_CHECKOUT', ['enabled' => false]);
$features->remove('NEW_CHECKOUT');

$participants = $client->organizations($organizationId)->participants();
$participants->create(['key' => 'CUSTOMER_123', 'notes' => 'Example participant']);
$participant = $participants->show('CUSTOMER_123');
$attributes = $participants->attributes('CUSTOMER_123');
$attributes->update([['key' => 'plan', 'value' => 'pro']]);
$attributes->list();
$attributes->remove('plan');
$attributes->remove(); // Removes all attributes.

$participants->experiments('CUSTOMER_123')->list();
$participants->experiments('CUSTOMER_123')->show('CHECKOUT');
$participants->experiments('CUSTOMER_123')->remove('CHECKOUT');

$pager = new Checkmango\ResultPager($client, 50);
$experiments = $pager->fetchAll($client->organizations($organizationId)->experiments(), 'list');
shell
composer