Download the PHP package simpleab/sdk-php without Composer
On this page you can find all versions of the php package simpleab/sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simpleab/sdk-php
More information about simpleab/sdk-php
Files in simpleab/sdk-php
Package sdk-php
Short Description PHP SDK for Captchify's SimpleAB A/B testing platform
License MIT
Informations about the package sdk-php
SimpleAB PHP SDK
This is the PHP SDK for SimpleAB, a powerful A/B testing platform by Captchify.
Installation
You can install the SimpleAB PHP SDK via Composer:
Usage
Here's a basic example of how to use the SimpleAB PHP SDK:
API Reference
SimpleABSDK
Constructor
$apiURL: The URL of the SimpleAB API. UseBaseAPIUrls::CAPTCHIFY_NAfor the North America API.$apiKey: Your SimpleAB API key.$experiments: (Optional) An array of experiment IDs to preload.
getTreatment
Gets the treatment for a given experiment, stage, dimension, and allocation key.
$experimentID: The ID of the experiment.$stage: The stage of the experiment. UseStages::PRODorStages::BETA.$dimension: The dimension of the experiment.$allocationKey: The allocation key for the user.
trackMetric
Tracks a metric for an experiment. The $params array should include:
experimentID: The ID of the experiment.stage: The stage of the experiment. UseStages::PRODorStages::BETA.dimension: The dimension of the experiment.treatment: The treatment assigned to the user.metricName: The name of the metric being tracked.metricValue: The value of the metric.aggregationType: The type of aggregation for the metric. UseAggregationTypes::SUM,AggregationTypes::AVERAGE, orAggregationTypes::PERCENTILE.
getSegment
Gets a segment for a user based on their IP address and user agent.
$options: An array containing:ip: The IP address of the user.userAgent: The user agent string of the user's browser.
Returns a Segment object.
getTreatmentWithSegment
Gets the treatment for a given experiment, stage, segment, and allocation key.
$experimentID: The ID of the experiment.$stage: The stage of the experiment. UseStages::PRODorStages::BETA.$segment: ASegmentobject obtained fromgetSegment().$allocationKey: The allocation key for the user.
trackMetricWithSegment
Tracks a metric for an experiment using a segment. The $params array should include:
experimentID: The ID of the experiment.stage: The stage of the experiment. UseStages::PRODorStages::BETA.segment: ASegmentobject obtained fromgetSegment().treatment: The treatment assigned to the user.metricName: The name of the metric being tracked.metricValue: The value of the metric.aggregationType: The type of aggregation for the metric. UseAggregationTypes::SUM,AggregationTypes::AVERAGE, orAggregationTypes::PERCENTILE.
flush
Flushes all tracked metrics to the SimpleAB API. Call this method before your script ends to ensure all metrics are sent.
Segment
The Segment class represents a user segment based on their location and device type.
File Structure
The SDK consists of the following files:
src/SimpleABSDK.php: The main SDK class.md5.php: A fallback MD5 implementation.composer.json: Composer package definition.LICENSE: MIT License file..gitignore: Git ignore file.README.md: This file.tests/SimpleABSDKTest.php: Unit tests for the SDK.
Development
To set up the project for development:
- Clone the repository.
- Run
composer installto install dependencies. - Make your changes in the
src/SimpleABSDK.phpfile. - Add or modify tests in the
testsdirectory.
Running Tests
To run the unit tests for the SimpleAB PHP SDK, follow these steps:
-
Ensure you have PHPUnit installed. It should be installed automatically when you run
composer install. -
From the root directory of the project, run the following command:
This will execute all the tests in the
testsdirectory. -
To run a specific test file, you can specify the file name:
- For more detailed output, you can use the
--verboseflag:
Make sure to run the tests after making any changes to the SDK to ensure that everything is working as expected.
License
This SDK is distributed under the MIT License. See the LICENSE file for more information.
Support
For support, please contact [email protected] or visit our documentation at https://captchify.com.