PHPackages                             phpfluent/arraystorage - 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. phpfluent/arraystorage

ActiveLibrary

phpfluent/arraystorage
======================

1.4.0(11y ago)37634[1 PRs](https://github.com/PHPFluent/ArrayStorage/pulls)MITPHP

Since Aug 16Pushed 6y ago6 watchersCompare

[ Source](https://github.com/PHPFluent/ArrayStorage)[ Packagist](https://packagist.org/packages/phpfluent/arraystorage)[ Docs](http://github.com/PHPFluent/ArrayStorage)[ RSS](/packages/phpfluent-arraystorage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

PHPFluent\\ArrayStorage
=======================

[](#phpfluentarraystorage)

[![Build Status](https://camo.githubusercontent.com/6baa8615dedbe2f44150ec46fb278839aeea03948f84170c6a479ea487e06639/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f504850466c75656e742f417272617953746f726167652e706e67)](http://travis-ci.org/PHPFluent/ArrayStorage)[![Total Downloads](https://camo.githubusercontent.com/038c7ab555eb170a16118a3de4f0e540ebb01995c2340cc46797b29e5f6ee2b0/68747470733a2f2f706f7365722e707567782e6f72672f706870666c75656e742f617272617973746f726167652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/phpfluent/arraystorage)[![License](https://camo.githubusercontent.com/a088c424a9471445242a53dab8b783d0dd4c95d4856139ee765e75593ca7b4ee/68747470733a2f2f706f7365722e707567782e6f72672f706870666c75656e742f617272617973746f726167652f6c6963656e73652e706e67)](https://packagist.org/packages/phpfluent/arraystorage)[![Latest Stable Version](https://camo.githubusercontent.com/c905d1f15911958c74184019b4ed4fa4a5c9167c6f188925bb4f18cd4f19a13f/68747470733a2f2f706f7365722e707567782e6f72672f706870666c75656e742f617272617973746f726167652f762f737461626c652e706e67)](https://packagist.org/packages/phpfluent/arraystorage)[![Latest Unstable Version](https://camo.githubusercontent.com/d00b3e0a5afa46b13b433f50f9953b4c73d66ec55a36a438d36a0b2ebc19f9b3/68747470733a2f2f706f7365722e707567782e6f72672f706870666c75656e742f617272617973746f726167652f762f756e737461626c652e706e67)](https://packagist.org/packages/phpfluent/arraystorage)

Non-persistent way to use arrays as *database*.

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

[](#installation)

Package is available on [Packagist](https://packagist.org/packages/phpfluent/arraystorage), you can install it using [Composer](http://getcomposer.org).

```
composer require phpfluent/arraystorage
```

Usage
=====

[](#usage)

The examples below are using the following use statement at the beginning of the file:

```
use PHPFluent\ArrayStorage\Storage;
```

Creating and returning a collection
-----------------------------------

[](#creating-and-returning-a-collection)

```
$storage = new Storage();
$storage->users; // This is a collection
```

Inserting records to a collection
---------------------------------

[](#inserting-records-to-a-collection)

You can use a single array:

```
$storage = new Storage();
$storage->users->insert(['name' => 'Henrique Moody']);
```

But you also can use a Record object:

```
use PHPFluent\ArrayStorage\Record;

$storage = new Storage();
$record = new Record();
$record->name = 'Henrique Moody';

$storage->users->insert($record);
```

You can create a Record object from Storage object:

```
$storage = new Storage();

$record = $storage->users->record(); // You also can provide default data, like an array or stdClass
$record->name = 'Henrique Moody';

$storage->users->insert($record);
```

An important point to note is that, after you insert the record to the collection object it gives to the record an unique (incremental integer) `id` property.

Removing records from a collection
----------------------------------

[](#removing-records-from-a-collection)

```
$storage = new Storage();
$storage->users->delete(['name' => 'Henrique Moody']);
```

Removing all records from a collection
--------------------------------------

[](#removing-all-records-from-a-collection)

```
$storage = new Storage();
$storage->users->delete();
```

Finding multiple records into a collection
------------------------------------------

[](#finding-multiple-records-into-a-collection)

```
$storage->users->findAll(['status !=' => false]); // Return an Collection object with the partial result (if any)
```

Finding single record into a collection
---------------------------------------

[](#finding-single-record-into-a-collection)

```
$storage->users->find(['priority >=' => 4]); // Return an Record object with the first matched result (if any) or NULL
```

Using Criteria object
---------------------

[](#using-criteria-object)

```
$criteria = $storage->users->criteria();
$criteria->foo->equalTo(2)
         ->bar->in([1, 2, 3])
         ->baz->regex('/^[0-9]{3}$/')
         ->qux->like('This _s spart%')
         ->quux->iLike('tHiS _S sPaRt%')
         ->corge->between(array(1, 42))
         ->grault->lessThan(1000)
         ->garply->greaterThan(0)
         ->waldo->notEqualTo(false)
         ->fred->greaterThanOrEqualTo(13);

$storage->users->find($criteria);
```

Transforming data into other formats
------------------------------------

[](#transforming-data-into-other-formats)

Sometimes you want to convert data into other formats, for that cases we have the *converters*.

The converters accept any object that implements [Traversable](http://php.net/traversable)interface and since `Record`, `Collection` and `Storage` classes implements this interface you are able to convert any of them into other formats.

For the examples below we assume you have the follow `use` statements:

```
use PHPFluent\ArrayStorage\Converter;
```

### Arr

[](#arr)

Converts data into an array.

```
$converter = new Converter\Arr();
$converter->convert($storage->collectionName); // Returns an array with the records as array too
```

If you do not want to convert the children of the object (values that also implement [Traversable](http://php.net/traversable) interface) you just have to define a flag on the constructor of this converter, like:

```
$converter = new Converter\Arr(false);
$converter->convert($storage->collectionName); // Returns an array of Record objects
```

### Json

[](#json)

Converts data into JSON format.

```
$converter = new Converter\Json();
$converter->convert($storage->collectionName); // Returns an string with the JSON
```

You also can define [json\_encode()](http://php.net/json_encode) options on the constructor of this converter, like:

```
$converter = new Converter\Json(JSON_NUMERIC_CHECK);
$converter->convert($storage->collectionName); // Returns the JSON but encodes numeric strings as numbers
```

We use `JSON_PRETTY_PRINT` as default option.

### Xml

[](#xml)

Converts data into XML format.

```
$converter = new Converter\Xml();
$converter->convert($storage->collectionName); // Returns an string with the XML
```

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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 ~5 days

Total

5

Last Release

4261d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/154023?v=4)[Henrique Moody](/maintainers/henriquemoody)[@henriquemoody](https://github.com/henriquemoody)

---

Top Contributors

[![henriquemoody](https://avatars.githubusercontent.com/u/154023?v=4)](https://github.com/henriquemoody "henriquemoody (39 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/phpfluent-arraystorage/health.svg)

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

PHPackages © 2026

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