PHPackages                             ronolo/json-store - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. ronolo/json-store

ActiveLibrary[File &amp; Storage](/categories/file-storage)

ronolo/json-store
=================

A lightweight JSON document store, which can be queried like a NoSQL database.

1.3.2(5y ago)214MITPHPPHP &gt;= 7.2CI failing

Since Dec 4Pushed 5y ago2 watchersCompare

[ Source](https://github.com/RoNoLo/json-store)[ Packagist](https://packagist.org/packages/ronolo/json-store)[ Docs](http://github.com/ronolo/json-store)[ RSS](/packages/ronolo-json-store/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (11)Used By (0)

Json-Store
==========

[](#json-store)

A document store which uses any type of filesystem to store documents as JSON. It uses  to abstract the storage space.

As by definition a *store* acts like ONE table in a database. You can put everything into one store or have many stores for different JSON objects.

It uses a NoSQL like query system for the documents and aims to use very low memory footprint (aka not loading all documents into memory to process them).

Note: There is a ronolo/json-database package, which uses the json-store and extends it with document relations (foreign keys) and query result caching.

Usage
-----

[](#usage)

First create a Config object.

Then specify the adapter which shall be used to actually store the JSON files to a disc/cloud/memory/zip. See to find the one which fits your needs. You have to init the adapter with the correct parameters.

```
// First create the config object
$config = new Store\Config();
// Set the the adapter
$config->setAdapter(new Local('some/path/persons'));
// Secondly create the JsonDB
$store = new Store($config);
```

The store is now ready. We can now store, read, delete and update documents. As a very basic usage, we can read every document back by ID.

Note: Update is always an update of the whole object. It is not possible to update single fields via store command.

As a speed bonus the store keeps all document IDs in an index file, which will be loaded on store construct. Another speed bonus would be to use the caching and speedup adapters found on the  page.

```
$document = file_get_contents('file/with/json/object.json');
// store a document
$id = $store->put($document);
// read a document
$document = $store->read($id);
// update document
$document->foobar = "Heinz";
$store->put($document);
// remove document
$store->remove($id);
```

It is also possible to query documents in a CouchDB like fashion from the store.

```
$query = new Store\Query($store);
$result = $query->find([
    "name" => "Bernd"
]);

// An iterator can be used to fetch one by one all documents

foreach ($result as $id => $document) {
    ; // do something with the document
}
```

There are the following conditions implemented:

```
[
    '$eq' => 'isEqual',
    '$neq' => 'isNotEqual',
    '$gt' => 'isGreaterThan',
    '$gte' => 'isGreaterThanOrEqual',
    '$lt' => 'isLessThan',
    '$lte' => 'isLessThanOrEqual',
    '$in'    => 'isIn',
    '$nin' => 'isNotIn',
    '$null' => 'isNull',
    '$n' => 'isNull',
    '$notnull' => 'isNotNull',
    '$nn' => 'isNotNull',
    '$contains' => 'contains',
    '$c' => 'contains',
    '$ne' => 'isNotEmpty',
    '$e' => 'isEmpty',
    '$regex' => 'isRegExMatch',
]
```

Examples can be found in the subdirectories of tests/src/query.

A few examples from there:

```
// SELECT * FROM store WHERE age = 20 OR age = 30 OR age = 40;
$query = new Store\Query($store);
$result = $query
    ->find([
        ["age" => 20],
        ["age" => 30],
        ["age" => 40]
    ])
    ->execute()
;

// SELECT index, guid FROM store ORDER BY index ASC LIMIT 60;
$query = new Store\Query($store);
$result = $query
    ->find([])
    ->fields(["index", "guid"])
    ->sort("index", "asc")
    ->limit(60)
    ->execute()
;

// SELECT * FROM store WHERE age = 20 AND phone = '12345' OR age = 40;
$query = new Store\Query($store);
$result = $query
    ->find([
        '$or' => [
            [
                "age" => [
                    '$eq' => 20,
                ],
                "phone" => [
                    '$eq' => "12345",
                ]
            ],
            [
                "age" => [
                    '$eq' => 40
                ]
            ]
        ]
    ])
    ->execute()
;
```

Goals
-----

[](#goals)

- No real database needed like SqlLite, Mysql, MongoDB, CouchDB ...)
- PHP 7.2+
- Document Store aka NoSQL
- JSON as format of storage
- (very) low memory usage even for huge results
- NoSQL like query syntax (CouchDB style)
- Abstract data location via

Limitations
-----------

[](#limitations)

- Any limitation the underlying flysystem adapter has
- If the creation of an unique ID fails, there will be an exception

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Recently: every ~0 days

Total

10

Last Release

2094d ago

Major Versions

0.9.0 → 1.2.02020-10-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17102148?v=4)[Ronald Locke](/maintainers/RoNoLo)[@RoNoLo](https://github.com/RoNoLo)

---

Top Contributors

[![RoNoLo](https://avatars.githubusercontent.com/u/17102148?v=4)](https://github.com/RoNoLo "RoNoLo (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

nosqlstoragejsonfilenosqldbdocument

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ronolo-json-store/health.svg)

```
[![Health](https://phpackages.com/badges/ronolo-json-store/health.svg)](https://phpackages.com/packages/ronolo-json-store)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.5M85](/packages/unisharp-laravel-filemanager)[alexusmai/laravel-file-manager

File manager for Laravel

1.2k803.2k9](/packages/alexusmai-laravel-file-manager)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6134.8M156](/packages/league-flysystem-sftp-v3)[jamesmoss/flywheel

A lightweight, flat-file, document database

33516.7k5](/packages/jamesmoss-flywheel)[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

191192.5k18](/packages/fof-upload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
