2017 © Pedro PelĂĄez
 

library reloquent

Simple object-data mapper for Redis and Laravel.

image

johnnymn/reloquent

Simple object-data mapper for Redis and Laravel.

  • Monday, February 1, 2016
  • by johnnymn
  • Repository
  • 1 Watchers
  • 18 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status Join the chat at https://gitter.im/johnnymn/reloquent, (*1)

Reloquent

A simple Object - Data Mapper for Laravel and Redis

Reloquent let you handle your Redis data as php objects allowing you to use it in a more friendly fashion. So you can think of it as a minimal Eloquent clone for redis (hence the name). Right now is basic in terms of functionality, and it doesn't allow querying models by its attributes (only the primary key), but I have plans to make that happen soon using Redis Sets (right now the library use redis Hashes as data structure for storing models). So in action:, (*2)

Installation

composer require johnnymn/reloquent

Then you a have to add:, (*3)

Reloquent\ReloquentServiceProvider::class

to your array of providers in the config/app.php file of laravel., (*4)

To publish the config file of the package you can use the following command:, (*5)

php artisan vendor:publish --provider=Reloquent\ReloquentServiceProvider

this is gonna copy a reloquent.php file in your laravel config folder. There you can configure your Redis instance details. Right now only single client config is available., (*6)

Usage

There is an artisan console command that helps you creating new models:, (*7)

php artisan reloquent:model MyModelName

This makes a basic model skeleton for you that extends the Reloquent\Model class and contains some properties:, (*8)

$fields = These are the names of the allowed fields you want in your model. If you try to set a field that is not listed here the model is not gonna set it., (*9)

$hidden = These are the fields that are not gonna appear in the json representation of the model., (*10)

$visible = The fields that are gonna appear in the json represenation of the model. If you leave it blank all fields are gonna appear., (*11)

$prefix = The prefix that the keys of the model gonna have. Think of it as the table name., (*12)

$key = The name of the key field of the model., (*13)

Notes

Reloquent its not an aim to change redis nature, just to make it more accesible. So there are some things that aren't in the actual scope. For example:, (*14)

  • The $key value is used to insert and locate a model, but the library its not gonna prevent you of overwriting another model, if you need taht behaivor you need to check if the key exists with the find method.

Docs

Getting into reloquent is very easy due to the fact that the api is based on eloquent model class. Right now the implemented methods are:, (*15)

  • save, (*16)

  • delete, (*17)

  • destroy, (*18)

  • find, (*19)

  • all, (*20)

  • create, (*21)

The complete API Docs: Reloquent Docs, (*22)

Data types

Redis supports a lot of data types as values of its keys, so you can store numbers, strings, files, etc. If you need more in deep info reffer to redis docs., (*23)

The Versions

01/02 2016

dev-master

9999999-dev

Simple object-data mapper for Redis and Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Johnny MartĂ­nez

31/01 2016

v0.1.1

0.1.1.0

Simple object-data mapper for Redis and Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Johnny MartĂ­nez