Download the PHP package namshi/ab without Composer

On this page you can find all versions of the php package namshi/ab. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ab

NAMSHI | AB

Build Status

SensioLabsInsight

This library provides a layer to run AB tests on your applications.

AB testing is useful when you want to change anything on your application but want to benchmark different variations of the change (ie. display a button that says "Buy now", "Go to checkout" or "PAY, DUDE!").

Installation

This library is available through composer, as you can see from its packagist page.

Just require it in your composer.json:

Creating and running a test

Creating tests is very simple, as you only need to define the test name and the variations, with their absolute probability:

and at this point you can change the color of the homepage by simply running the test and checking which variation has been picked:

Of course, the mess of a code above is here just as an example ;-)

Handling multiple tests

Taken by an AB-test-rage, you might want to start using AB tests for everything: that's why we added a test container where you can register as much tests as you want, and retrieve them easily:

The Container implements the ArrayAccess and Countable interfaces, so that you can access its tests like if it is an array:

Variations

Variations' weight must be expressed in absolute values: if, for example, you have A: 1, B: 2 and C: 1, that means that the percentage of picking each variation is 25% (A), 50% (B) and 25%(C), as the sum of the weights is 4.

Variations can be set while constructing the test or later on:

Remember to set the variations before running the test with getVariation, else an exception is thrown:

How to present the same variations across multiple requests

Let's say that you are running a test that defines whether the background color of your website should be black or white.

Once a user hits the homepage, he will get the white one, but as soon as he refreshes the page he might get the black one!

To be consistent with the variations, for a user's session, you should store a unique number (seed) and pass it to the tests before running them, so you will always be sure that specific user will always get the same variations of the tests:

In the next request, since the seed won't change, the user will get again the same variation, black.

This functionality is implemented thanks to PHP's mt_rand and mt_srand functions.

You shouldn't specify a different seed for each of your tests, but use the container instead:

The advantage of setting the seed through the container is that you don't have to maintain a seed for every test you run in the session, you can just use a global seed and the container will assign a unique seed to each test.

Disabling tests

Sometimes you might want to disable tests for different purposes, for example if the user agent who is visiting the page is a bot.

Once you disable the test and run it, it will always return the first variation, no matter what its odds are! Yes, even zero...

Test parameters

You can also attach any parameter you want to a test by just injecting them (or with the set method):

So that you can then easily retrieve them in other parts of the code:

Testing this library

This library has been unit tested with PHPUnit, so just cd into its folder and run phpunit.


All versions of ab with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package namshi/ab contains the following files

Loading the files please wait ....