checkmango/php-sdk

The PHP SDK for Checkmango

Fund package maintenance!
jbrooksuk

v1.0.0 2023-10-11 19:01 UTC

This package is auto-updated.

Last update: 2024-10-11 21:18:27 UTC


README

This project is heavily inspired by Graham Campbell's packages; Bitbucket and GitLab.

Installation

This version supports PHP 7.2-8.2. To get started, require the project using Composer. You will also need to install packages that provide psr/http-client-implementation and psr/http-factory-implementation.

Standard Installation

composer require "checkmango/php-sdk:dev-master" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"

Laravel Installation

composer require "checkmango/laravel:dev-master" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"

Usage

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

// Example API Call
$experiment = $client->teams($teamId)->experiments()->show('EXPERIMENT_KEY');

$client->teams($teamId)->ingest()->store('EXPERIMENT_KEY', 'PARTICIPANT_KEY', 'VARIANT_KEY'); // Track impression
$client->teams($teamId)->ingest()->store('EXPERIMENT_KEY', 'PARTICIPANT_KEY', 'VARIANT_KEY', 'EVENT_KEY'); // Track conversion

Example with Pager

The Pager class allows you to easily retrieve all results across multiple pages of results.

$pager = new Checkmango\ResultPager($client);
$experiments = $pager->fetchAll($client->teams($teamId)->experiments(), 'all');

Security

If you discover a security vulnerability within this package, please email James Brooks at james@checkmango.com. All security vulnerabilities will be promptly addressed. You may view our full security policy here.

License

Checkmango PHP SDK is licensed under The MIT License (MIT).