Download the PHP package czim/laravel-datastore without Composer
On this page you can find all versions of the php package czim/laravel-datastore. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download czim/laravel-datastore
More information about czim/laravel-datastore
Files in czim/laravel-datastore
Package laravel-datastore
Short Description Laravel data store framework.
License MIT
Homepage https://github.com/czim
Informations about the package 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
Currently a WIP under heavy development.
Version Compatibility
Laravel | Package |
---|---|
5.4 - 5.8 | 1.1 |
6.0 | 2.0+ |
7.0 | 2.1 |
Installation
Via Composer
Add the DataStoreServiceProvider
to your config/app.php
:
Publish the configuration file.
Filtering
If you intend to make use of the (default) filtering functionality of this package, you should add the czim/laravel-filter dependency:
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
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
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
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
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:
- Write an implementation of
Czim\DataStore\Contracts\Stores\Includes\IncludeDecoratorInterface
. - 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.<your model class>
.
- Either as the default include decorator, in
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:
Contributing
Please see CONTRIBUTING for details.
Credits
- Coen Zimmerman
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-datastore with dependencies
czim/laravel-dataobject Version ^1.0|^2.0
illuminate/support Version ^5|^6|^7