Download the PHP package indigophp/ruler without Composer

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

Indigo Ruler

Latest Version Build Status Code Coverage Quality Score HHVM Status Total Downloads Dependency Status

Library to process logical rules and apply outcomes based on the result of those rules.

Install

Via Composer

Usage

The package consists of Rules, Assertions, Resultss, Modifiers, RuleSets and a Processor.

The main process centers around the Processor. This is responsible for taking a Context and a Target to work out which sets of rules are valid and applying their results. The Processor takes a Context and applies Rules to it. If the Rules pass then a Modifier is applied to the Target to modify one or more of the Target's properties.

The Context is the data that is being inspected whilst the Target is the data that is being modified and is passed by reference. Both can be an array or object or whatever you want and both can be the same thing.

The Processor expects to be passed one or more RuleSets. A RuleSet is a combination of a single Rule and one or more Modifiers.

A Rule is combined with an Assertion to perform logical assertions on the Context. Rules should be able to select data from the Context and then should apply an Assertion to this data to return a boolean value to indicate success or failure.

A Result should modify data within the Target. They work in much the same way as Rules in that they select data and pass this to a Modifier and apply the result.

RuleSet Diagram

Processor Flow

Sample code

Why is this all so complicated

While this whole process might seem complicated it allows for great flexibility when it comes to creating user-buildable rules. The Rules and Results allow a user to pinpoint a single piece of data and define how to examine and modify it.

Builder

The Builder class can be used to create sets of rules quickly from an array structure. This first requires setting up the various libraries so the Builder can create the needed classes for you.

The format of the array is represented here.

Manager

The Manager class can be used to keep track of multiple sets of the libraries that Builder requires. Used in conjunction with a DIC solution this can provide you with an easy way to manage multiple rule "environments".

For example, if you used the logic processor to process rules for product promotions and taxes you most likely want to use different rules and results for both. Using the Manager class you can set up an environment for each to be able to quickly create rule sets for both.

Adding a new environment is done via the Manager::addEnvironment() method, this takes a name and four "things" for each needed library for Rule, Assertion, Result and Modifier. The "thing" can be an array, string or callable.

If an array or ArrayAccess is passed then a new library object is created and populated with the values in the array using AbstractLibrary::add() with the array keys as the name.

If the thing passed is callable then it is expected to return an instance of LibraryInterface.

Finally if the above conditions are not met then the value is treated as a string class name and the Manager will attempt to construct it as a new object, passing nothing to the constructor.

Testing

Contributing

Please see CONTRIBUTING for details.

Credits

Based on the work of Steve West (original name: LogicProcessor).

License

The MIT License (MIT). Please see License File for more information.

Originally licensed by Ve Interactive under the MIT License.


All versions of ruler with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
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 indigophp/ruler contains the following files

Loading the files please wait ...