Download the PHP package rogervila/php-simple-rules-engine without Composer

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

PHP Simple Rules Engine

Build Status StyleCI Quality Gate Status Coverage

Latest Stable Version Total Downloads License

PHP Simple Rules Engine

About

Evaluate rules based on a subject.

Usage

The package expects a subject and a list of rules.

Each rule must be a class that extends \SimpleRulesEngine\Rule.

The subject parameter can be any type of object (mixed)

Basic usage

Rules return a \SimpleRulesEngine\Evaluation object that should contain a result property defined by the user.

Also, the user can define the value of the stop property to determine if the evaluation process should stop or continue.

In this example, the stop property value does not affect the evaluation process since we are evaluating only one rule.

Advanced usage

When evaluating multiple rules you can retrieve the history of the rules evaluated for a specific evaluation process by passing the withHistory parameter as true.

The final \SimpleRulesEngine\Evaluation object will contain a history list with evaluations returned by the rules evaluated during the evaluation process.

Check test_evaluation_with_history method on tests/RulesEngineTest.php for a more detailed implementation.

Recursive usage

You might pass rules and array of rules to recursively evaluate them.

Note: A future version of this library might come with Openswoole support to parallelize the evaluation of each subset of rules.

Examples

The examples are very simple for demo purposes, but they show the basic features this package comes with.

There is a python rules engine called durable rules that comes with some examples. We will recreate them with this package.

Pattern matching

Find a credit card type based on its number.

Check test_match_example_with_cards method on tests/RulesEngineTest.php for a more detailed implementation.

Set of facts

Find an animal based on facts.

In this case, we will compare the current rule result with the previous evaluation result. If they match, we stop the evaluation process.

Check test_facts_example method on tests/RulesEngineTest.php for a more detailed implementation.

Author

Created by Roger Vilà

License

PHP Simple Rules Engine is open-sourced software licensed under the MIT license.

Icons made by Gregor Cresnar from www.flaticon.com

All versions of php-simple-rules-engine with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 rogervila/php-simple-rules-engine contains the following files

Loading the files please wait ....