PHPackages                             alternatex/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. alternatex/store

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

alternatex/store
================

Lightweight storage wrapper

1.0.11(12y ago)042MITJavaScriptPHP &gt;=5.3.0

Since Oct 12Pushed 12y ago1 watchersCompare

[ Source](https://github.com/alternatex/store)[ Packagist](https://packagist.org/packages/alternatex/store)[ Docs](http://alternatex.github.io/store)[ RSS](/packages/alternatex-store/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (4)Versions (13)Used By (0)

Store
=====

[](#store)

[![Build Status](https://camo.githubusercontent.com/12051ee3ac7c86bd74f6862937be9e921f2cfb64f4dff8a80f7515c38106a806/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f616c7465726e617465782f73746f72652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/alternatex/store)

A lightweight datastore wrapper providing CRUD operations for arbitrary objects.

Index
-----

[](#index)

- [Quickstart](#quickstart)
    - [Embedding](#embedding)
- [Client API](#client-api)
    - [Store](#store-1)
        - [Configure](#configure)
        - [Create](#create)
    - [Object](#object)
        - [Create](#create-1)
        - [Read](#read)
        - [Update](#update)
        - [Delete](#delete)
    - [Summary](#summary)
- [Server API](#server-api)
- [Repositories](#repositories)\* [File Stores](#file-stores)\* [CSV](#csv)\* [JSON](#json)\* [Serialized](#serialized)
- [Documentation](#documentation)
- [Roadmap](#roadmap)
- [License](#license)

Quickstart
----------

[](#quickstart)

### Embedding

[](#embedding)

#### Require.js

[](#requirejs)

```
require(["store"], function(Store) {
  // ...
});
```

#### HTML

[](#html)

```

```

Client API
----------

[](#client-api)

### Store

[](#store-1)

#### Configure

[](#configure)

Defaults are configured as follows:

```
Store.configure({
  url: "http://localhost/datastore.php",
  ttl: 3600
});
```

**Note**

`configure()` alters the prototype object, hence modifications are propagated to instances on property level given that the respective instance properties have not been modified previously.

#### Create

[](#create)

```
var objectStore = new Store({ namespace: 'object' });
```

### Object

[](#object)

#### Create

[](#create-1)

##### Preset

[](#preset)

```
var object = objectStore.create({
  country: 'USA',
  firstname: 'Stephen',
  lastname: 'Colbert'
});
```

##### Barebone

[](#barebone)

```
var object = objectStore.create();
object.set('country', 'USA');
object.set('firstname', 'Jon');
object.set('lastname', 'Stewart');
```

#### Read

[](#read)

##### List

[](#list)

```
objectStore.list();
```

##### Single

[](#single)

```
objectStore.get('8c0c1ff0-d0fe-38b7-376a-b0b1d53bd557');
```

#### Update

[](#update)

##### Instance

[](#instance)

```
object.update();
```

##### Datastore

[](#datastore)

```
objectStore.update(object);
```

#### Delete

[](#delete)

##### Instance

[](#instance-1)

```
object.remove();
```

##### Datastore

[](#datastore-1)

```
objectStore.remove(object);
```

### Summary

[](#summary)

```

(function(){

  // local variables
  var object, objectId, objectStore, objects;

  // configure store defaults
  Store.configure({
    url: "http://localhost/store/examples/server.php",
    ttl: 3600
  });

  // create new store
  objectStore = new Store({ namespace: 'object' });

  // create new store bound object
  object = objectStore.create({
    country: 'US',
    firstname: 'Stephen',
    lastname: 'Colbert'
  });

  // update on insert
  objectStore.update(object).done(function(object){

    // wrap json object
    object = objectStore.create(object);

    // update properties
    object.set('firstname', 'Jon');
    object.set('lastname', 'Stewart');

    // extract
    objectId = object.get('id');

    // update object
    objectStore.update(object).done(function(object){

        // fetch object w/previously retrieved objectId
        objectStore.get(objectId).done(function(object){

           // wrap json object
           object = objectStore.create(object);

           // say hi
           console.log(object.get('firstname') + " " + object.get('lastname'));
        });
    });
  });

  // collect update promises
  objects = [];

  // create some objects
  Store.times(10, function(count){

    // store update promises
    objects.push(objectStore.create({
      title: 'No.' + count,
      abstract: 'Lorem Ipsum [...]',
      text: 'Lorem Ipsum Si Amet They Say',
      author: 'me',
      lastmod: new Date().getTime()
    }).update());
  });

  // when all objects have been updated
  Store.when(objects).done(function(objects){

    // fetch all objects
    objects = objectStore.list();

    // print when object have been retrieved
    Store.when(objects).done(function(objects){

      // log each
      objects.forEach(function(object, index){
        console.log(index, object);
      });
    });
  });

  // fetch object
  object = objectStore.get(objectId);

  // process fetched object
  Store.when(object).done(function(object){

    // execute on success
    console.info("done", object);

  }).fail(function(objects){

    // execute on fail
    console.error("fail", objects);

  }).always(function(objects){

    // always execute this block
    console.log("always", objects);

  });

})();

  Update

```

### Routes

[](#routes)

...

Server API
----------

[](#server-api)

[![Latest Stable Version](https://camo.githubusercontent.com/fba3f10e4f5f1cc963ea2101cc2ff20d7ddbf379d665047319fa25e4f3096429/68747470733a2f2f706f7365722e707567782e6f72672f616c7465726e617465782f73746f72652f762f737461626c652e706e67)](https://packagist.org/packages/alternatex/store)[![Dependency Status](https://camo.githubusercontent.com/dd7850513666566eb01c2b8302559d71f1709780fa60374bc0221cf830cebce4/68747470733a2f2f64617669642d646d2e6f72672f616c7465726e617465782f73746f72652e706e67)](https://david-dm.org/alternatex/store)

Repositories
------------

[](#repositories)

### File Stores

[](#file-stores)

Collections stored on a file basis.

**Limitations**

Built with prototyping in mind. Won't scale.

#### CSV

[](#csv)

...

#### JSON

[](#json)

Supports embedding binary data base64 encoded.

#### Serialized

[](#serialized)

Stores data using PHPs `serialize()` function. Supports embedding binary data base64 encoded.

Documentation
-------------

[](#documentation)

- [API](http://alternatex.github.io/store/docs/)
- [Examples](http://alternatex.github.io/store/examples/)

Roadmap
-------

[](#roadmap)

- Access Control
- Synchronization
- JSON Schema
    - Generators

License
-------

[](#license)

Released under two licenses: new BSD, and MIT. You may pick the license that best suits your development needs.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

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

Total

10

Last Release

4656d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac27eb99c62840e871b46be66372378247888420f733e215efe5b6dde6d0718c?d=identicon)[alternatex](/maintainers/alternatex)

---

Top Contributors

[![alternatex](https://avatars.githubusercontent.com/u/634067?v=4)](https://github.com/alternatex "alternatex (174 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k199.6M3.4k](/packages/composer-composer)[paycore/openfintech-data

Openfintech data

22310.1k](/packages/paycore-openfintech-data)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k30.0M2.8k](/packages/infection-infection)[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

200569.1k3](/packages/wikimedia-parsoid)[pantheon-systems/terminus

A command line interface for Pantheon

3441.5M20](/packages/pantheon-systems-terminus)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k17.3k100](/packages/elgg-elgg)

PHPackages © 2026

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