Download the PHP package stellarwp/field-conditions without Composer

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

Introduction

This is a small PHP library for defining and processing field conditions. By "field" conditions we're referring to conditions for use with a set of fields, such as a form. A field condition consists of a field name, a comparison operator, the value to compare against, and the logical operator to use when combining multiple conditions. For example:

This condition would be true if the value of the field named "name" is equal to "John".

Finally, all conditions can be serialized into JSON. The intended scenario is for passing said conditions to the front-end to be used in JavaScript. Simply use the json_encode() function to serialize the condition or condition set.

Installation

It is recommended to install this library using Composer. To do so, run the following command:

If using this in WordPress, it is strongly recommended that you use Strauss to avoid conflicts with other plugins.

Configuration

The library includes a Config class which can be used for setting configuration options. At this time, the only configuration is the ability to override the InvalidArgumentException, in case you need your own exception to be used here.

How to use

Typically, conditions will be stored within a ConditionSet object. This object tracks the conditions and provides methods for determining whether the conditions pass or fail a given set of data.

There are two types of conditions:

There are two types of condition sets:

Defining your conditions

First, you will want to instantiate your condition set. If you only want a flat set of conditions that cannot be nested, then use a SimpleConditionSet. Otherwise, use a ComplexConditionSet.

Next, you can pass your conditions to the condition set:

Condition instances can also be passed to the where, and, and or methods. Note that the logical operator in the condition will be overwritten by the method used.

It's also possible to append conditions to an existing condition set:

Checking values against conditions

Once you have your condition set, you will want to pass values to the condition set to check whether the given data passes the set of conditions.

A note about logical operators (and/or) in conditions

One thing that may be confusing is how logical operations work in conditions. Consider the following:

Logically, this reads as "name equals John OR age is greater than 18". What makes this feel strange is that the logical operator appears at the end of the second condition. This makes it feel like the OR is being applied to the end of the second condition. In reality, the OR is being applied to the start of the condition.

The logical operator is applied to the start of the condition, as the logical operation applies to the current condition, not the next. This is why the typical way to write the sets is using the where(), and(), and or() methods, so it feels more natural.

Lastly, the default logical operator is AND, so it is only necessary to specify the logical operator when using OR.


All versions of field-conditions with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
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 stellarwp/field-conditions contains the following files

Loading the files please wait ....