PHPackages                             phpnomad/datastore - 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. phpnomad/datastore

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

phpnomad/datastore
==================

2.0.3(3w ago)05.7k↓16.4%[2 issues](https://github.com/phpnomad/datastore/issues)[1 PRs](https://github.com/phpnomad/datastore/pulls)7MITPHPCI passing

Since Apr 11Pushed 3w ago2 watchersCompare

[ Source](https://github.com/phpnomad/datastore)[ Packagist](https://packagist.org/packages/phpnomad/datastore)[ Docs](https://github.com/phpnomad/core)[ RSS](/packages/phpnomad-datastore/feed)WikiDiscussions main Synced yesterday

READMEChangelog (5)Dependencies (2)Versions (12)Used By (7)

phpnomad/datastore
==================

[](#phpnomaddatastore)

[![Latest Version](https://camo.githubusercontent.com/9f09ee6656673f187867a63a25a228878aa83521af01267a7ceac24cd1693c2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6f6d61642f6461746173746f72652e737667)](https://packagist.org/packages/phpnomad/datastore) [![Total Downloads](https://camo.githubusercontent.com/39be0d4b4c9a21086b50d6b0f86ab4d9f8e9343428f8adf06b6d4ff94fa10f8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706e6f6d61642f6461746173746f72652e737667)](https://packagist.org/packages/phpnomad/datastore) [![PHP Version](https://camo.githubusercontent.com/fbd9afbafed5a2f6e155da270c3d282ebf01286f978d0e417ec3aa0840eaa93e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068706e6f6d61642f6461746173746f72652e737667)](https://packagist.org/packages/phpnomad/datastore) [![License](https://camo.githubusercontent.com/4e55241f5554414e3043776185eb8851c45632d78ddff1a00203c1fac626144a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6f6d61642f6461746173746f72652e737667)](https://packagist.org/packages/phpnomad/datastore)

`phpnomad/datastore` is the storage-agnostic data access pattern at the heart of [PHPNomad](https://phpnomad.com). It ships a small set of interfaces, traits, models, and events that let your business logic describe what data operations it needs without committing to where the data lives. It contains no concrete storage code of its own.

The pattern splits into two layers. Your Core layer holds the `Datastore` interface your application code depends on, the `DatastoreHandler` interface that storage implementations fulfill, and the domain models that flow between them. Your Service layer holds concrete handlers that talk to real storage, whether that's a SQL database, a REST API, a GraphQL endpoint, or an in-memory array for tests. `phpnomad/db` is one Service-layer implementation against SQL, and PHPNomad has been running this pattern in production for years, powering [Siren](https://sirenaffiliates.com), several MCP servers, and other client systems.

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

[](#installation)

```
composer require phpnomad/datastore
```

Quick Start
-----------

[](#quick-start)

The pattern centers on three files: a `Datastore` interface (your public API), a `DatastoreHandler` interface (the storage contract), and a Core implementation that wires them together with decorator traits.

Declare your public API by extending the base interfaces you need and adding any custom business methods:

```
