PHPackages                             czim/laravel-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. [API Development](/categories/api)
4. /
5. czim/laravel-datastore

AbandonedArchivedLibrary[API Development](/categories/api)

czim/laravel-datastore
======================

Laravel data store framework.

2.1.2(6y ago)66.1k1[1 issues](https://github.com/czim/laravel-datastore/issues)MITPHPPHP &gt;=7.2

Since Aug 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/czim/laravel-datastore)[ Packagist](https://packagist.org/packages/czim/laravel-datastore)[ Docs](https://github.com/czim)[ RSS](/packages/czim-laravel-datastore/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (10)Versions (16)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/aee01d86dd345be784513c73aab5513b7a69e2224769712821918265496859e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f637a696d2f6c61726176656c2d6461746173746f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/czim/laravel-datastore)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/98480c060abe6a4661028a2225c7e7febb511653c5b75ef9d4412eccebccb7a9/68747470733a2f2f7472617669732d63692e6f72672f637a696d2f6c61726176656c2d6461746173746f72652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/czim/laravel-datastore)[![Coverage Status](https://camo.githubusercontent.com/5114f2b96e3a23149166330782aadf84717e834bed3b549ab2de19ca7b895e5c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f637a696d2f6c61726176656c2d6461746173746f72652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/czim/laravel-datastore?branch=master)

Laravel Datastore
=================

[](#laravel-datastore)

Basic datastore framework for building APIs.

This is intended to be combined with a (JSON-API) transformer/serialization layer.

This approach will allow you to separate responsibilities between serialization and transformation (the API representation layer) and data access abstraction.

Disclaimer
----------

[](#disclaimer)

Currently a WIP under heavy development.

Version Compatibility
---------------------

[](#version-compatibility)

LaravelPackage5.4 - 5.81.16.02.0+7.02.1Installation
------------

[](#installation)

Via Composer

```
$ composer require czim/laravel-datastore
```

Add the `DataStoreServiceProvider` to your `config/app.php`:

```
Czim\DataStore\Providers\DataStoreServiceProvider::class,
```

Publish the configuration file.

```
$ php artisan vendor:publish
```

### Filtering

[](#filtering)

If you intend to make use of the (default) filtering functionality of this package, you should add the [czim/laravel-filter](https://github.com/czim/laravel-filter) dependency:

```
$ composer require czim/laravel-filter
```

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

[](#documentation)

This data store package is split up, responsibility-wise, into two layers: the resource adapter and the data store itself.

A data store is responsible for retrieving and manipulating data. The resource adapter is an interface layer between the data store and the incoming and outgoing data (which can be JSON-API, or any custom transformation/formatting layer that you choose to implement).

### Data Stores

[](#data-stores)

Available data stores:

- `\Czim\DataStore\Stores\EloquentDataStore`Simple Model data store.
- `\Czim\DataStore\Stores\EloquentDataStore`Store to use if you have a repository (`Czim\Repository\Contracts\BaseRepositoryInterface`) available.

### Resource Adapter

[](#resource-adapter)

This package only provides a resource adapter set-up for JSON-API out of the box, expecting you to use `czim/laravel-jsonapi`. For any other implementation, you're encouraged to write your own adapter. This package has been designed to make it easy to swap out (custom) implementations, provided some familiarity with Laravel's container and provisioning.

### Retrieval Context

[](#retrieval-context)

The context for retrieving information (filters, sorting, pagination) is defined in interfaces. A `RequestContext` object may be filled with data in any way, and then passed into the data store to restrict or sort the results. No specific implementation is assumed for this.

### Includes

[](#includes)

By default, the resource (adapter) and client input determine the includes that will be used for eager loading. Eager loading is then performed on the basis of simple string relation names as `with()` parameters.

For more flexibility, it is possible to configure include decorators to further control eager loading. To make use of this:

1. Write an implementation of `Czim\DataStore\Contracts\Stores\Includes\IncludeDecoratorInterface`.
2. Configure this class in the `datastore.php` configuration file:
    - Either as the default include decorator, in `datastore.include.decorator.default`,
    - or mapped for a specific class under `datastore.include.decorator.model-map.`.

The `decorate()` method on the decorator will be fed a resolved array of dot-notated include strings, that can be manipulated and returned as desired.

Example:

```
use Czim\DataStore\Contracts\Stores\Includes\IncludeDecoratorInterface;
use Illuminate\Database\Eloquent\Model;

class CustomIncludeDecorator implements IncludeDecoratorInterface
{
    public function setModel(Model $model)
    {
        // Ignore or store and use the model as desired.
    }

    public function decorate(array $includes, $many = false)
    {
        // Replace a specific include with a closure to eager load with specific columns.
        if (in_array('someRelation', $includes)) {
            $includes = array_diff($includes, ['someRelation']);
            $includes['someRelation'] = function ($query) {
                return $query->select(['id', 'title']);
            };
        }

        // Never eager load a specific relation.
        $includes = array_diff($includes, ['neverEagerLoadThis.relation']);

        // Always eager load some specific relation.
        $includes[] = 'translations';

        return $includes;
    }
}
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Coen Zimmerman](https://github.com/czim)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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 ~76 days

Recently: every ~85 days

Total

14

Last Release

2246d ago

Major Versions

0.1.1 → 1.1.22017-09-16

1.1.9 → 2.0.02019-09-18

PHP version history (2 changes)0.1.0PHP &gt;=5.6.4

2.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1657b09521b6030fe32d864a493ded8b1dbbdf737ef3772135dfc123cea34767?d=identicon)[czim](/maintainers/czim)

---

Top Contributors

[![czim](https://avatars.githubusercontent.com/u/11831617?v=4)](https://github.com/czim "czim (20 commits)")[![daniel-de-wit](https://avatars.githubusercontent.com/u/3015394?v=4)](https://github.com/daniel-de-wit "daniel-de-wit (2 commits)")

---

Tags

apidata-access-layerdatastorejson-apilaravelapilaraveldata storeData Abstraction

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/czim-laravel-datastore/health.svg)

```
[![Health](https://phpackages.com/badges/czim-laravel-datastore/health.svg)](https://phpackages.com/packages/czim-laravel-datastore)
```

###  Alternatives

[resend/resend-laravel

Resend for Laravel

1212.2M8](/packages/resend-resend-laravel)[essa/api-tool-kit

set of tools to build an api with laravel

53386.5k](/packages/essa-api-tool-kit)[smodav/mpesa

M-Pesa API implementation

16167.1k1](/packages/smodav-mpesa)

PHPackages © 2026

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