Install
Require via Composer:
$ composer require shiny/json-logic-php
Or add to your composer.json:
{
"require": {
"shiny/json-logic-php": "^1.0"
}
}
Usage
<?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
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.