Download the PHP package jwadhams/json-logic-php without Composer

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

json-logic-php

This parser accepts JsonLogic rules and executes them in PHP.

The JsonLogic format is designed to allow you to share rules (logic) between front-end and back-end code (regardless of language difference), even to store logic along with a record in a database. JsonLogic is documented extensively at JsonLogic.com, including examples of every supported operation and a place to try out rules in your browser.

The same format can also be executed in JavaScript by the library json-logic-js

Examples

A note about types

This is a PHP interpreter of a format designed to be transmitted and stored as JSON. So it makes sense to conceptualize the rules in JSON.

Expressed in JSON, a JsonLogic rule is always one key, with an array of values.

PHP has a way to express associative arrays as literals, and no object equivalent, so all these examples are written as if JsonLogic rules were decoded with json_decode's $assoc parameter set true, e.g.

The library will happily accept either associative arrays or objects:

Simple

This is a simple test, equivalent to 1 == 1. A few things about the format:

  1. The operator is always in the "key" position. There is only one key per JsonLogic rule.
  2. The values are typically an array.
  3. Each value can be a string, number, boolean, array, or null

Compound

Here we're beginning to nest rules.

In an infix language (like PHP) this could be written as:

Data-Driven

Obviously these rules aren't very interesting if they can only take static literal data. Typically JsonLogic::apply will be called with a rule object and a data object. You can use the var operator to get attributes of the data object:

If you like, we support syntactic sugar on unary operators to skip the array around values:

You can also use the var operator to access an array by numeric index:

Here's a complex rule that mixes literals and data. The pie isn't ready to eat unless it's cooler than 110 degrees, and filled with apples.

Always and Never

Sometimes the rule you want to process is "Always" or "Never." If the first parameter passed to JsonLogic::apply is a non-object, non-associative-array, it is returned immediately.

Installation

The best way to install this library is via Composer:

If that doesn't suit you, and you want to manage updates yourself, the entire library is self-contained in src/JWadhams/JsonLogic.php and you can download it straight into your project as you see fit.


All versions of json-logic-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.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 jwadhams/json-logic-php contains the following files

Loading the files please wait ....