PHPackages                             xnan/hydra - 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. xnan/hydra

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

xnan/hydra
==========

Simple persistent data structures for PHP

0.9.2(4y ago)19[7 issues](https://github.com/xnan-dev/Hydra/issues)MITPHPPHP ^7.2.5 || ^8.0

Since May 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/xnan-dev/Hydra)[ Packagist](https://packagist.org/packages/xnan/hydra)[ RSS](/packages/xnan-hydra/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Hydra
=====

[](#hydra)

Simple persistent data structures for small projects
----------------------------------------------------

[](#simple-persistent-data-structures-for-small-projects)

The aim is solve the common demand for many php web projects to have some kind of permanent state shared within an application which cannot be accomplished very well using session object (either because implies an all-or-nothing heavy object serialization or because the state is required to be shared between user session boundaries. Also, state might be needed to persist throughout reboots.

A usual approach to solve this problems is using a relational database but for rapid prototyping or small project it adds a big overhead going back and forth between queries and relational structure definitions. This library with some simple passive persistent data structures, all native, might offer a more confortable solution.

installing Hydra
----------------

[](#installing-hydra)

```
composer require xnan/hydra

```

Setting up the library
----------------------

[](#setting-up-the-library)

```
use xnan\Trurl\Hydra;
Hydra\Functions::Load;

(Hydra\hydra())->hydrate();

// create or update your data structures.

(Hydra\hydra())->dehydrate(); // stores all new or changed structures.
```

Using Maps
----------

[](#using-maps)

```
$m=(Hydra\hydra())->maps()->retrieveOrCreateHMap(999,"testMap");

$m->set("w","hello");

if ($m->hasKey("w")) echo $m->get("w");  // echoes hello
```

Using Matrixes
--------------

[](#using-matrixes)

```
$m=(Hydra\hydra())->matrixes()->retrieveOrCreateHMatrix(1,"testMatrix",[10,20]);

$m->set([5,10],33.3);
$v=$m->get([5,10]); // 33.3
```

Supported data structures
-------------------------

[](#supported-data-structures)

Currently, these are the supported data structures:

- Matrix
- Map
- Object references

Hydra properties
----------------

[](#hydra-properties)

- Passive library
    - it does not require to setup any service or deamon, it runs only when called.
- Simple object storage
    - object values assigned to persistent maps or references are stored by standard php serialization.
- Thread safe storage
    - at storage time, objects are locked for exclusive write.
- No setup policy
    - data structures are meant to adjust its properties according to usage, provide a reasonable default setting is considered a must.

Data structures storage
-----------------------

[](#data-structures-storage)

All structures are stored in folder content/Hydra in php serialized form. For Matrix structure, a more compact binary storage is used.

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

1497d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ae31e28298db43726308fafd42fc5a30c963e4de3ad1ada3cbbb8f1cff48d91?d=identicon)[hrancati](/maintainers/hrancati)

---

Top Contributors

[![xnan-dev](https://avatars.githubusercontent.com/u/105134243?v=4)](https://github.com/xnan-dev "xnan-dev (15 commits)")

---

Tags

persistencestoragedbstateless

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xnan-hydra/health.svg)

```
[![Health](https://phpackages.com/badges/xnan-hydra/health.svg)](https://phpackages.com/packages/xnan-hydra)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k679.9M2.5k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[sylius/resource-bundle

Resource component for Sylius.

23610.8M235](/packages/sylius-resource-bundle)[google/cloud

Google Cloud Client Library

1.2k16.7M57](/packages/google-cloud)[microsoft/azure-storage-common

This project provides a set of common code shared by Azure Storage Blob, Table, Queue and File PHP client libraries.

4318.0M6](/packages/microsoft-azure-storage-common)[league/flysystem-async-aws-s3

AsyncAws S3 filesystem adapter for Flysystem.

2812.1M44](/packages/league-flysystem-async-aws-s3)

PHPackages © 2026

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