Download the PHP package arekx/array-expression-engine without Composer

On this page you can find all versions of the php package arekx/array-expression-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 array-expression-engine

Array Expression Engine

Scrutinizer Code Quality Build Status Code Coverage

This is an array expression parser which can be used to parse values using configuration specified in PHP arrays. These arrays can be loaded from anywhere, like from JSON string, PHP files, etc.

These expressions are used to configure the expression parser engine which runs a value through the rules defined in the array expression to return a result.

Installation

Run composer require arekx/array-expression-engine in your project.

Usage

Operators

Summary

Following operators are available:

Operator Name Definition
AND AND operator ['and', <expression1>, ..., <expressionN>]
OR OR operator ['or', <expression1>, ..., <expressionN>]
XOR XOR operator (exclusive OR) ['xor', <expression1>, ..., <expressionN>]
NOT NOT operator (inverts check) ['not', <expression>]
BETWEEN BETWEEN operator, checks if the value is between minimum and maximum (inclusive) ['between', <valueExpression>, <minExpression>, <maxExpression>]
COMPARE Comparison operator ['compare', <expressionA>, <expressionB>], ['compare, <expressionA>, '=', <expressionB>]
REGEX Regex operator ['regex', <expression>, '/pattern/'], ['regex', <expression>, <patternExpression>]
VALUE Value operator, returns static values ['value', 'this is a static value']
GET GET operator, returns values by name from passed value ['get', 'keyFromValue']
CONCAT CONCAT operator, concatenates strings ['concat', <expression1>, ..., <expressionN>]
AND Operator

AND operator is defined in ArekX\ArrayExpression\Operators\AndOperator class and is used to represent AND operation between two or more expressions, those expressions can by any other operator including AND operator.

Example:

OR Operator

OR operator is defined in ArekX\ArrayExpression\Operators\OrOperator class and is used to represent OR operation between two or more expressions, those expressions can by any other operator including OR operator.

Example:

XOR Operator

XOR operator is defined in ArekX\ArrayExpression\Operators\XOrOperator class and is used to represent XOR operation between two or more expressions, those expressions can by any other operator including XOR operator.

Example:

NOT Operator

Not operator is defined in ArekX\ArrayExpression\Operators\NotOperator class and is used to represent NOT operation or the inversion of the expression passed to it.

Example:

BETWEEN Operator

Between operator is defined in ArekX\ArrayExpression\Operators\BetweenOperator class and is used to check if a value is between minimum and maximum value.

Example:

COMPARE Operator

Comparison operator for comparing two expressions. It is defined in ArekX\ArrayExpression\Operators\CompareOperator.

Comparison operator accepts multiple formats:

Short format

['compare', <expressionA>, <expressionB>]

Checks if <expressionA> equals (strict) to <expressionB>

Relation format

['compare', <expressionA>, '>=', <expressionB>]

Checks if <expressionB> is greater or equal to <expressionB> and returns true/false

Supported relation operators:

Example:

REGEX Operator

REGEX operator is defined in ArekX\ArrayExpression\Operators\RegexOperator class and is used to check if a value matches a specific regex pattern.

Regex operator accepts multiple formats:

String format

['regex', <expression>, '/pattern/']

Checks if <expression> matches specific pattern. Return value from <expression> must be a string.

Expression format

['regex', <expression>, <expressionFormat>]

Checks if <expression> matches specific pattern defined by <expressionFormat>.

Return value from <expression> must be a string.

Return value from <expressionFormat> must be a string.

Example:

Value Operator

Value operator is defined in ArekX\ArrayExpression\Operators\ValueOperator class and is used to return a static value.

Example:

Get Operator

Get operator is defined in ArekX\ArrayExpression\Operators\GetOperator class and is used to return a value from a key.

Example:

Concat Operator

Concat operator is defined in ArekX\ArrayExpression\Operators\ConcatOperator class and is used to concatenate two or more strings. It requires evaluation results to be strings.

Example:

Custom operators

You can create your own custom operator manually by implementing Operator interface and adding that operator to ExpressionParser of your Evaluator.

We will implement a custom operator which transforms all instances of a word cat into dog.

Operator definition we want to implement is: ['dog', <expression>]

First we implement an Operator class

After creating this class we need to add it to the evaluator's expression parser and we are set:

Tests

Run composer test to run tests.


All versions of array-expression-engine with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 arekx/array-expression-engine contains the following files

Loading the files please wait ....