seatgeek/sixpack-php
最新稳定版本:2.1
Composer 安装命令:
composer require seatgeek/sixpack-php
包简介
Sixpack A/B testing framework client
README 文档
README
Sixpack
PHP client library for SeatGeak's Sixpack ab testing framework.
Installation
- Install Composer
- In the root of your project install sixpack via
composer require seatgeek/sixpack-php - In your php script put
require 'vendor/autoload.php';at the top so sixpack is loaded.
Usage
Basic example:
The PHP client stores a unique client id in the current user's cookie by default.
require 'vendor/autoload.php'; $sp = new \SeatGeek\Sixpack\Session\Base; $alt = $sp->participate('test', array('blue', 'red'))->getAlternative(); if ($alt == 'blue') { /* do something blue */ } else { /* do somethign red */ }
Each session has a client_id associated with it that must be preserved across requests. The PHP client handles this automatically. If you'd wish to change that behavior, you can do so like this:
require 'vendor/autoload.php'; $sp = new \SeatGeek\Sixpack\Session\Base; $resp = $sp->participate("new-test", array("alternative-1", "alternative-2")); store_in_database("sixpack-id", $resp->getClientId());
For future requests, create the Session using the client_id stored in the cookie:
require 'vendor/autoload.php'; $client_id = get_from_database("sixpack-id") $sp = new \SeatGeek\Sixpack\Session\Base(array('clientId' => $client_id)); $sp->convert('new-test');
Other possible options for the Session constructor are:
- baseUrl - Sixpack Server's location on the web
- cookiePrefix - you can set a different prefix for the cookie if you like. Default is
sixpack
If you'd like to force the Sixpack server to return a specific alternative for development or testing, you can do so by passing a query parameter named sixpack-force to that page being tested.
http://example.com/?sixpack-force-<experiment name>=<alternative name>
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
License
sixpack-php is released under the BSD 2-Clause License.
统计信息
- 总下载量: 207.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 75
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2013-02-08