Download the PHP package featurevisor/featurevisor-php without Composer

On this page you can find all versions of the php package featurevisor/featurevisor-php. 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 featurevisor-php

Featurevisor PHP SDK

This is a port of Featurevisor Javascript SDK v2.x to PHP, providing a way to evaluate feature flags, variations, and variables in your PHP applications.

This SDK is compatible with Featurevisor v2.0 projects and above.

Table of contents

In your PHP application, install the SDK using Composer:

Initialization

The SDK can be initialized by passing datafile content directly:

Evaluation types

We can evaluate 3 types of values against a particular feature:

These evaluations are run against the provided context.

Context

Contexts are attribute values that we pass to SDK for evaluating features against.

Think of the conditions that you define in your segments, which are used in your feature's rules.

They are plain objects:

Context can be passed to SDK instance in various different ways, depending on your needs:

Setting initial context

You can set context at the time of initialization:

This is useful for values that don't change too frequently and available at the time of application startup.

Setting after initialization

You can also set more context after the SDK has been initialized:

This will merge the new context with the existing one (if already set).

Replacing existing context

If you wish to fully replace the existing context, you can pass true in second argument:

Manually passing context

You can optionally pass additional context manually for each and every evaluation separately, without needing to set it to the SDK instance affecting all evaluations:

When manually passing context, it will merge with existing context set to the SDK instance before evaluating the specific value.

Further details for each evaluation types are described below.

Check if enabled

Once the SDK is initialized, you can check if a feature is enabled or not:

You can also pass additional context per evaluation:

Getting variation

If your feature has any variations defined, you can evaluate them as follows:

Additional context per evaluation can also be passed:

Getting variables

Your features may also include variables, which can be evaluated as follows:

Additional context per evaluation can also be passed:

Type specific methods

Next to generic getVariable() methods, there are also type specific methods available for convenience:

Getting all evaluations

You can get evaluations of all features available in the SDK instance:

This is handy especially when you want to pass all evaluations from a backend application to the frontend.

Sticky

For the lifecycle of the SDK instance in your application, you can set some features with sticky values, meaning that they will not be evaluated against the fetched datafile:

Initialize with sticky

Once initialized with sticky features, the SDK will look for values there first before evaluating the targeting conditions and going through the bucketing process.

Set sticky afterwards

You can also set sticky features after the SDK is initialized:

Setting datafile

You may also initialize the SDK without passing datafile, and set it later on:

Updating datafile

You can set the datafile as many times as you want in your application, which will result in emitting a datafile_set event that you can listen and react to accordingly.

The triggers for setting the datafile again can be:

Interval-based update

Here's an example of using interval-based update:

@TODO

Logging

By default, Featurevisor SDKs will print out logs to the console for info level and above.

Levels

These are all the available log levels:

Customizing levels

If you choose debug level to make the logs more verbose, you can set it at the time of SDK initialization.

Setting debug level will print out all logs, including info, warn, and error levels.

Alternatively, you can also set logLevel directly:

You can also set log level from SDK instance afterwards:

Handler

You can also pass your own log handler, if you do not wish to print the logs to the console:

Further log levels like info and debug will help you understand how the feature variations and variables are evaluated in the runtime against given context.

Events

Featurevisor SDK implements a simple event emitter that allows you to listen to events that happen in the runtime.

You can listen to these events that can occur at various stages in your application:

@TODO: verify these events

datafile_set

The features array will contain keys of features that have either been:

compared to the previous datafile content that existed in the SDK instance.

context_set

sticky_set

Evaluation details

Besides logging with debug level enabled, you can also get more details about how the feature variations and variables are evaluated in the runtime against given context:

The returned object will always contain the following properties:

And optionally these properties depending on whether you are evaluating a feature variation or a variable:

Hooks

Hooks allow you to intercept the evaluation process and customize it further as per your needs.

Defining a hook

A hook is a simple object with a unique required name and optional functions:

Registering hooks

You can register hooks at the time of SDK initialization:

Or after initialization:

Child instance

When dealing with purely client-side applications, it is understandable that there is only one user involved, like in browser or mobile applications.

But when using Featurevisor SDK in server-side applications, where a single server instance can handle multiple user requests simultaneously, it is important to isolate the context for each request.

That's where child instances come in handy:

Now you can pass the child instance where your individual request is being handled, and you can continue to evaluate features targeting that specific user alone:

Similar to parent SDK, child instances also support several additional methods:

Close

Both primary and child instances support a .close() method, that removes forgotten event listeners (via on method) and cleans up any potential memory leaks.

CLI usage

This package also provides a CLI tool for running your Featurevisor project's test specs and benchmarking against this PHP SDK:

Test

Learn more about testing here.

Additional options that are available:

Benchmark

Learn more about benchmarking here.

Assess distribution

Learn more about assessing distribution here.

Development of this package

Setting up

Clone the repository, and install the dependencies using Composer:

Running tests

Releasing

License

MIT © Fahad Heylaal


All versions of featurevisor-php 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 featurevisor/featurevisor-php contains the following files

Loading the files please wait ....