https://github.com/dimgraycat/php-split-testing
https://github.com/dimgraycat/php-split-testing
ab-testing packagist php php-library
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dimgraycat/php-split-testing
- Owner: dimgraycat
- License: mit
- Created: 2017-01-13T01:40:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-11T06:02:45.000Z (over 5 years ago)
- Last Synced: 2025-12-14T22:08:17.295Z (7 months ago)
- Topics: ab-testing, packagist, php, php-library
- Language: PHP
- Size: 486 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/dimgraycat/php-split-testing/blob/master/LICENSE)
[](https://packagist.org/packages/dimgraycat/split-testing)
[](https://php.net/)
[](https://travis-ci.org/dimgraycat/php-split-testing)
# SplitTesting
A server-side A/B/n testing tool
This library provides a layer to run AB tests on your applications.
The "SplitTesting" is useful when you want to change something on the application, but you want to check the optimize by using various variations.
## Installation
```bash
$ composer require dimgraycat/split-testing
```
```json
{
"require": {
"dimgraycat/split-testing": "^1.0"
}
}
```
And install dependencies:
```bash
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
```
## Usage
### Random
```php
'random',
'variation' => array(
'foo',
'bar',
'baz'
);
);
$result = SplitTesting::get($params);
// $seed is optional
// e.g.) userId, IpAddress
$seed = 1234;
echo SplitTesting::get($params, $seed);
```
### Rate (Roulette)
```php
'rate',
'variation' => array(
'rate' => array(
// 1 => 0.1%, 50 => 5%, 500 => 50%, 1000 => 100%
'foo' => 50,
'bar' => 20,
'baz' => 500,
),
'list' => array(
'default' => array('hoge'),
'a' => '5%',
'hoge' => 1234567890,
'moge' => '123456789',
),
),
);
echo SplitTesting::get($params);
```
### PatternMatch
```php
'pattern',
'variation' => array(
'pattern' => array(
'foo' => '/[0-9]$/',
'bar' => '/z$/',
),
'list' => array(
'default' => 'default',
'foo' => 'hit 1!',
'bar' => 'hit 2!'
),
),
);
$seed = 1234; // required
echo SplitTesting::get($params, $seed); // hit 1!
```