Download the PHP package rasuvaeff/yii3-ab-testing-db without Composer

On this page you can find all versions of the php package rasuvaeff/yii3-ab-testing-db. 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 yii3-ab-testing-db

rasuvaeff/yii3-ab-testing-db

Stable Version Total Downloads Build Static Analysis PHP

Database-backed experiment provider for Yii3 A/B testing. Implements the ExperimentProvider interface from rasuvaeff/yii3-ab-testing and reads experiment configuration from a database table in a single query, so experiments can be toggled and reweighted at runtime without a deploy.

Using an AI coding assistant? llms.txt contains a compact API reference you can ingest in your prompt context.

Requirements

Installation

With Yii3 config-plugin this package binds ExperimentProvider automatically — do not also bind ExperimentProvider in your application or another backend, or yiisoft/config reports a Duplicate key error.

Database schema

Create the ab_experiments table (adjust types for your RDBMS):

Column Type Default Description
name VARCHAR(190) PK Experiment name (core regex: /^[a-z][a-z0-9_-]*$/)
enabled BOOLEAN true Disabled experiment returns the fallback variant
salt VARCHAR(190) '' Empty string falls back to the experiment name
fallback_variant VARCHAR(190) '' Must be one of the variants keys
variants JSON/TEXT '{}' JSON object {"variant": weight}, non-negative integer weights

A row's variants looks like {"control":50,"green":50}. The total weight must be greater than zero and fallback_variant must match one of the keys, or the row is rejected with InvalidExperimentRowException.

Migration

The package ships a migration (migrations/) for yiisoft/db-migration. Register the source path in your app's config/params.php:

Then apply and revert it with Yii Console:

The table name defaults to ab_experiments and must match the table argument of DbExperimentProvider. To use a custom name, bind the migration constructor argument:

Usage

Basic DB provider

With PSR-16 caching

getExperiments() runs on every registry build (per request). Without caching that is a DB query per request — wrap the provider in CachedExperimentProvider:

Clear cache

API reference

Class Description
DbExperimentProvider Reads all experiments from DB in one SELECT *
CachedExperimentProvider PSR-16 decorator, caches the entire experiment set with TTL
InvalidExperimentRowException Thrown when a DB row has invalid structure or yields an invalid experiment

Security

Examples

See examples/ for runnable scripts.

Development

License

BSD-3-Clause. See LICENSE.md.


All versions of yii3-ab-testing-db with dependencies

PHP Build Version
Package Version
Requires php Version 8.3 - 8.5
ext-json Version *
psr/simple-cache Version ^3.0
rasuvaeff/yii3-ab-testing Version ^1.4
yiisoft/db Version ^2.0
yiisoft/db-migration Version ^2.0
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 rasuvaeff/yii3-ab-testing-db contains the following files

Loading the files please wait ...