JSONLogic Shiny JSON Logic

shiny/json-logic-php

The most compliant PHP implementation of JSON Logic. 100% of official tests. PHP 8.1+.

601/601 official tests
100% spec compliant
PHP 8.1+ supported

Install

Require via Composer:

Terminal
$ composer require shiny/json-logic-php

Or add to your composer.json:

composer.json
{
  "require": {
    "shiny/json-logic-php": "^1.0"
  }
}

Usage

app.php
<?php
require 'vendor/autoload.php';

use Shiny\JsonLogic\ShinyJsonLogic;

$rule = [">" => [[ "var" => "age" ], 18]];
$data = ["age" => 21];

ShinyJsonLogic::apply($rule, $data);
// => true

// Drop-in replacement — global aliases are registered automatically
JsonLogic::apply($rule, $data);   // also works
JSONLogic::apply($rule, $data);   // also works

Try it live

Rule (JSON Logic) logic
Data (JSON) input
Ruby shiny_json_logic
Hit Evaluate to see the result
JavaScript json-logic-engine
Hit Evaluate to see the result

How does it compare?

Feature shiny/json-logic-php jwadhams/json-logic-php
Official tests 100% 63.9%
Last updated 2026 2024
PHP 8.x
Strict types

Why shiny/json-logic-php?

100% Spec Compliant

Passes all 601 official JSON Logic tests from the json-logic community. No edge cases swept under the rug.

Drop-in Replacement

Registers JsonLogic and JSONLogic as global aliases automatically. Switch packages in your composer.json — no code changes needed.

Modern PHP

Written for PHP 8.1+ with strict types, clean namespacing, and proper autoloading. The original library hasn't been updated since 2020.

Actively Maintained

Built and maintained by contributors to the JSON Logic specification. Issues are addressed. PRs are welcome.

Using Ruby instead?

Shiny JSON Logic is also available as a Ruby gem — same spec compliance, same API.

shiny_json_logic →