matraux/json-orm

A PHP 8.4+ library for converting JSON data to typed entities and back, with support for lazy-loading collections.

Maintainers

Package info

github.com/matraux/json-orm

pkg:composer/matraux/json-orm

Statistics

Installs: 271

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

3.0.0 2026-03-12 13:51 UTC

This package is auto-updated.

Last update: 2026-03-29 12:42:29 UTC


README

Latest Version on Packagist Last release License: MIT PHP Security Policy Contributing QA Status Issues Last Commit


Introduction

A PHP 8.4+ library for converting JSON data to typed entities and back, with support for lazy-loading collections, mutable data structures, and structured entity design. Useful for structured JSON APIs, configuration parsing, and object-based manipulation of hierarchical JSON data.


Features

  • Object-oriented JSON mapping
  • Conversion from JSON to typed entities and back
  • Lazy-loading collections for efficient memory usage
  • Entity objects are mutable and can be freely modified after creation
  • Strict type support with automatic casting and codec transformations
  • Native support for nested structures and arrays
  • Easy integration with configuration or API responses

Installation

composer require matraux/json-orm

Requirements

version PHP Note
1.0.0 7.4+ Support PHP 7.4
2.0.0 8.3+ Support PHP 8.3
3.0.0 8.4+ Support PHP 8.4

Examples

See Definitions for how to define your own entities and collections.

See Read for full reading examples.

use Matraux\JsonOrm\Json\SimpleExplorer;

// Load data from JSON string or file
$explorer = SimpleExplorer::fromString('[{"CUSTOM_ID":1,"name":"First"}]');

// Create typed collection from JSON
$collection = CommonCollection::fromExplorer($explorer);

$entity = $collection[0];
echo $entity->name; // "First"

See Write for writing examples.

// Create collection and insert entity
$collection = CommonCollection::create();

$entity = $collection->createEntity();
$entity->name = 'Example';

echo json_encode($collection);
// '[{"name":"Example"}]'

Development

See Development for debug, test instructions, static analysis, and coding standards.


Support

For bug reports and feature requests, please use the issue tracker.