PHPackages                             paragi/rocket-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. [Database &amp; ORM](/categories/database)
4. /
5. paragi/rocket-store

ActiveLibrary[Database &amp; ORM](/categories/database)

paragi/rocket-store
===================

A simple but powerfull database, based on flat file storage.

48PHP

Since Jun 13Pushed 6y ago2 watchersCompare

[ Source](https://github.com/paragi/rocket-store)[ Packagist](https://packagist.org/packages/paragi/rocket-store)[ RSS](/packages/paragi-rocket-store/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Rocket Store
============

[](#rocket-store)

Using the filesystem as a simple searchable database. It's lightning fast compared to a fullblown database. All packaged in a single file to include, without any dependencies. However, if you need the superior search and storage power of a real SQL RDBM, this simple tool does not compare.

Features:
---------

[](#features)

- Extremely fast
- Very reliant
- Very little footprint.
- Very flexible.
- No dependencies
- Works without configuration or setup.
- Records (arrays) are stored in editable text files.
- Very configurable
- Also available for node in javascript

Installation
------------

[](#installation)

All you need to do is to download the file 'rocket-store.php' and include it to your script.

#### To use composer:

[](#to-use-composer)

Install the package. [Composer](http://getcomposer.org/)

Execute the command: `composer require paragi/rocket-store`

To modify the `composer.json` manually, add `"paragi/rocket-store" : "^0.5"` to your `required`

Functions overview
------------------

[](#functions-overview)

### Post

[](#post)

Stores a record, in &lt;filename&gt;, in &lt;directory&gt; in the [storage area](#storage-area).

```
post(string ,string ,array | scalar  [, integer options])
```

- Directory name to contain the collection of file records.
- File name of the record No path separators or wildcards are allowed in directory or file names
- Options:
    - RS\_ADD\_AUTO\_INC: Add an auto incremented sequence to the beginning of the file name

Returns an array containing the result of the operation:

- error : string Empty or containing an error message i the operation failed.
- key: string containing the actual file name used
- count : number of files affected (1 on succes)

If the file already exists, the record will be replaced.

Subdirectories and full path is not supported. Path separators and other illigal charakters are silently striped off.

### Get

[](#get)

Find an retrieve a record, in &lt;filename&gt;, in &lt;directory&gt; in the [storage area](#storage-area).

```
get([string  [,string  [integer post("cars", "Mercedes-Benz GT R", ["owner" => "Lisa Simpson"]);

// GET a record
print_r(
    $rs->get("cars", "Mercedes*")
);
```

The above example will output this:

```
[error] =>
[result] => Array (
        [Mercedes-Benz GT R] => Array (
                [owner] => Lisa Simpson
        )
    )
[count] => 1

```

#### Inserting an auto inceremented key

[](#inserting-an-auto-inceremented-key)

File names must always be unique. If you have more than one instance of a file name, you can add an auto incremented sequence to the name:

```
$rs->post("cars", "BMW-740li",[ "owner" => "Greg Onslow"], RS_ADD_AUTO_INC);
$rs->post("cars", "BMW-740li", ["owner" => "Sam Wise"], RS_ADD_AUTO_INC);
$rs->post("cars", "BMW-740li", ["owner" => "Bill Bo"], RS_ADD_AUTO_INC);

print_r(
    $rs->get("cars", "*")
);
```

The above will output this:

```
[error] =>
[result] => Array(
        [1-BMW-740li] => Array (
                [owner] => Greg Onslow
            )
        [2-BMW-740li] => Array (
                [owner] => Sam Wise
            )
        [3-BMW-740li] => Array (
                [owner] => Bill Bo
            )
    )
[count] => 3

```

#### Inserting with Globally Unique IDentifier key

[](#inserting-with-globally-unique-identifier-key)

Another option is to add a GUID to the key. The GUID is a combination of a timestamp and a random sequence, formatet in accordance to RFC 4122 (Valid but slightly less random)

If ID's are generated more than 1 millisecond apart, they are 100% unique. If two ID's are generated at shorter intervals, the likelyhod of collission is up to 1 of 10^18.

```
$rs->post("cars", "BMW-740li",[ "owner" => "Greg Onslow"], RS_ADD_AUTO_INC);
$rs->post("cars", "BMW-740li", ["owner" => "Sam Wise"], RS_ADD_AUTO_INC);
$rs->post("cars", "BMW-740li", ["owner" => "Bill Bo"], RS_ADD_AUTO_INC);

print_r(
    $rs->get("cars", "*")
);
```

The above will output this:

```
[error] =>
[result] => Array(
        [16b511bc-1cf0-4000-867a-e3a22c073280-BMW-740li] => Array (
                [owner] => Greg Onslow
            )
        [16b50c59-1598-4000-83c7-679b458c2730-BMW-740li] => Array (
                [owner] => Sam Wise
            )
        [16b50c59-263c-4000-872b-f31ba07b97f0-BMW-740li] => Array (
                [owner] => Bill Bo
            )
    )
[count] => 3

```

#### Mass insterts

[](#mass-insterts)

```
$dataset = [
     "Gregs-BMW-740li" => ["owner" => "Greg Onslow"]
    ,"Lisas-Mercedes-Benz GT R" => ["owner" => "Lisa Simpson"]
    ,"Bills-BMW-740li" => ["owner" => "Bill Bo"]
];

foreach($dataset as $key => $record)
    $rs->post("cars", $key, $record);
```

#### Get records with matching keys

[](#get-records-with-matching-keys)

```
print_r(
    $rs->get("cars", "*BMW*")
);
```

The above example might output this:

```
[error] =>
[result] => Array(
        [1-BMW-740li] => Array (
                [owner] => Greg Onslow
            )
        [3-BMW-740li] => Array (
                [owner] => Bill Bo
            )
    )
[count] => 2

```

##### Get list ordered by alphabetically decending keys

[](#get-list-ordered-by-alphabetically-decending-keys)

```
$rs->get("cars", "*BMW*", RS_ORDER_DESC);
```

##### Get list of collections and sequences

[](#get-list-of-collections-and-sequences)

```
$rs->get();
```

#### Delete matching records from a collection

[](#delete-matching-records-from-a-collection)

```
$rs->delete("cars", "*BMW*");
```

The above example might output this:

```
    [error] =>
    [count] => 2
```

#### Delete a whole collection

[](#delete-a-whole-collection)

```
$rs->delete("cars");
```

#### Delete the entire database

[](#delete-the-entire-database)

```
$rs->delete();
```

---

Legal characters
----------------

[](#legal-characters)

keys, queries and collections is a string of printable characters excluding: '|' '&lt;' '&gt;' '~' '&amp;' '..' and the directory separator '/' or '' and ':' on windows. '\*' and '?' are allowed in queries. All other characters are striped from the string. Limitations on other charakters and lenght is imposed by the filesystem

---

Benchmarks
----------

[](#benchmarks)

The test is performed with 1 million records in in a single collection.

SystemMass insertexact key searchwildcard searchno hitdeleteSystem: i7 3rd gen on SSD69000/sec.87000/sec.14.6/sec.123000/sec.325/sec.Raspbarry Pi Zero561/sec.96/sec.0.27/sec.147/sec.0.29/sec.---

Remarks
-------

[](#remarks)

This class was made to optimize resources in an embedded project, with limited resources. But it quickly became apparent, that a generalized interface to the file systems awesome cashing capabilities was very useful in other areas as well. It's all to easy to stick with your stack. Even when you don't need its complexity. That approach can be taxing on both the global environment and very local economy, as bloated software use much more power. The goal of this project is to make it very simple to use the file system for storage purposes, with a few very versatile methods.

---

Contributions
-------------

[](#contributions)

- Contributions of any kind are highly appreciated.
- Don't hesitate to submit an issue on github. But please provide a reproducible example.
- Code should look good and compact, and be covered by a test case or example.
- Please don't change the formatting style laid out, without a good reason. I know its not the most common standard, but its rather efficient one.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a6095dc96c4ceea5a3de9b71d99834f1057f510a15b2cf6d7ec563138ef9fab?d=identicon)[paragi](/maintainers/paragi)

---

Top Contributors

[![paragi](https://avatars.githubusercontent.com/u/4333973?v=4)](https://github.com/paragi "paragi (17 commits)")

### Embed Badge

![Health badge](/badges/paragi-rocket-store/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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