Download the PHP package krystalcode/feature-toggle without Composer

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

SensioLabsInsight

Scrutinizer Code Quality Build Status Code Coverage Dependency Status Latest Stable Version License

FeatureToggle

About

FeatureToggle is an easy to use, extensible library that aims to provide feature toggle functionality for PHP applications.

Model

The library model is based on Toggles which are classes that define algorithms used to evaluate whether a feature should be on or off (enabled or disabled). Examples may be a Toggle that reads a configuration file and decides based on a variable value, a Toggle that checks whether the user has a subscription plan, or a Toggle that fetches information from an external API and decides based on that.

Requirements

Currently depends on the Symfony Yaml component (https://github.com/symfony/yaml).

How to use

Provided Toggles

YAML file

The YAML Toggle (ToggleConfigYaml class) loads the configuration variables from a YAML file and decides based on a variable value. It extends the ToggleConfig class which statically stores the configuration vatiables so that they are loaded only once even if feature toggling is used in multiple places in the code.

Assuming the following configuration file contents:

The following code will enable the feature on the development and stage environments and disable it on the production environment.

where the variable $yourCurrentEnvironment should have a value of "dev", "stage" or "prod". On runtime, the code will be executed in the development and staging environments but not in the production environment.

The configuration variables may also have other values apart from true or false. Say you would like to enable a feature only when the blue theme is in use:

The following code will enable the feature when the value of the variable "theme" is "blue".

PHP file

You can load the variables from a PHP configuration file. Using the same example as with YAML, your configuration file contents would be:

and your application code would be:

INI file

You can load the variables from an INI configuration file (.ini, see http://php.net/manual/en/function.parse-ini-file.php). Using the same example as with YAML, your configuration file contents would be:

and your application code would be:

Integrations

Yii Framework

You will need to add your configuration in the params.php file (Yii2) or in the main.php file (Yii1) as an array item with index 'featureToggle'. Using the same example as with YAML, your configuration file contents would be:

and your application code would be:

How to extend

Say you would like to enable a feature only for premium users on your website. You can write a custom Toggle as follows:

Full syntax

The examples above are using the easy syntax provided by a helper class. The full syntax for the YAML examples would be:

and

For PHP:

and for INI:

How to contribute

Feel free to submit pull requests. If you have ideas for new features or use cases that are not covered, open an issue to discuss.


All versions of feature-toggle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
symfony/yaml Version ^2.5.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 krystalcode/feature-toggle contains the following files

Loading the files please wait ....