Download the PHP package rinvex/repository without Composer

On this page you can find all versions of the php package rinvex/repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package repository

Rinvex Repository

Rinvex Repository Diagram

Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.

⚠️ This package is renamed and now maintained at rinvex/laravel-repositories, author suggests using the new package instead. Old package supportes up to Laravel v5.6, and the new one supports Laravel v5.7+

Packagist License VersionEye Dependencies Scrutinizer Code Quality Code Climate StyleCI SensioLabs Insight

💡 If you are looking for Laravel 5.5 support, use the dev-develop branch. It's stable but not tagged yet since test suites isn't complete. 💡

⚠️ This package is looking for new maintainer, read details or takeover if interested! ⚠️

Table Of Contents

Features

Installation

The best and easiest way to install this package is through Composer.

Compatibility

This package fully compatible with Laravel 5.1.*, 5.2.*, and 5.3.*.

While this package tends to be framework-agnostic, it embraces Laravel culture and best practices to some extent. It's tested mainly with Laravel but you still can use it with other frameworks or even without any framework if you want.

Prerequisites

Require Package

Open your application's composer.json file and add the following line to the require array:

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install Dependencies

On your terminal run composer install or composer update command according to your application's status to install the new requirements.

Note: Checkout Composer's Basic Usage documentation for further details.

Integration

Rinvex Repository package is framework-agnostic and as such can be integrated easily natively or with your favorite framework.

Native Integration

Integrating the package outside of a framework is incredibly easy, just require the vendor/autoload.php file to autoload the package.

Note: Checkout Composer's Autoloading documentation for further details.

Laravel Integration

Rinvex Repository package supports Laravel by default and it comes bundled with a Service Provider for easy integration with the framework.

After installing the package, open your Laravel config file located at config/app.php and add the following service provider to the $providers array:

Note: Checkout Laravel's Service Providers and Service Container documentation for further details.

Run the following command on your terminal to publish config files:

Note: Checkout Laravel's Configuration documentation for further details.

You are good to go. Integration is done and you can now use all the available methods, proceed to the Usage section for an example.

Configuration

If you followed the previous integration steps, then your published config file reside at config/rinvex.repository.php.

Config options are very expressive and self explanatory, as follows:

Usage

Quick Example

The Rinvex\Repository\Repositories\BaseRepository is an abstract class with bare minimum that concrete implementations must extend.

The Rinvex\Repository\Repositories\EloquentRepository is currently the only available repository implementation (more to come in the future and you can develop your own), it makes it easy to create new eloquent model instances and to manipulate them easily. To use EloquentRepository your repository MUST extend it first:

That's it, you're done! Yes, it's that simple.

But if you'd like more control over the container instance, or would like to pass model name dynamically you can alternatively to as follow:

Now inside your controller, you can either instantiate the repository traditionally through $repository = new \App\Repositories\FooRepository(); or to use Laravel's awesome dependency injection and let the IoC do the magic:

Rinvex Repository Workflow - Create Repository Rinvex Repository Workflow - Create Repository

Rinvex Repository Workflow - Use In Controller Rinvex Repository Workflow - Use In Controller

UML Diagram


You're good to go! That's pretty enough knowledge to use this package.

A good programmer is someone who always looks both ways before crossing a one-way street. -Doug Linder

So, you decided to proceed, ha?! Awesome!! :D


Detailed Documentation

setContainer(), getContainer()

The setContainer method sets the IoC container instance, while getContainer returns it:

setModel(), getModel()

The setModel method sets the repository model, while getModel returns it:

setRepositoryId(), getRepositoryId()

The setRepositoryId method sets the repository identifier, while getRepositoryId returns it (it could be anything you want, but must be unique per repository):

setCacheLifetime(), getCacheLifetime()

The setCacheLifetime method sets the repository cache lifetime, while getCacheLifetime returns it:

setCacheDriver(), getCacheDriver()

The setCacheDriver method sets the repository cache driver, while getCacheDriver returns it:

enableCacheClear(), isCacheClearEnabled()

The enableCacheClear method enables repository cache clear, while isCacheClearEnabled determines it's state:

createModel()

The createModel() method creates a new repository model instance:

forgetCache()

The forgetCache() method forgets the repository cache:

with()

The with method sets the relationships that should be eager loaded:

where()

The with method adds a basic where clause to the query:

whereIn()

The whereIn method adds a "where in" clause to the query:

whereNotIn()

The whereNotIn method adds a "where not in" clause to the query:

Note: All of the where, whereIn, and whereNotIn methods are chainable & could be called multiple times in a single request. It will hold all where clauses in an array internally and apply them all before executing the query.

offset()

The offset method sets the "offset" value of the query:

limit()

The limit method sets the "limit" value of the query:

orderBy()

The orderBy method adds an "order by" clause to the query:

find()

The find method finds an entity by it's primary key:

findBy()

The findBy method finds an entity by one of it's attributes:

findAll()

The findAll method finds all entities:

paginate()

The paginate method paginates all entities:

As you can guess, this query the first 15 records, in the second page.

simplePaginate()

The simplePaginate method paginates all entities into a simple paginator:

findWhere()

The findWhere method finds all entities matching where conditions:

findWhereIn()

The findWhereIn method finds all entities matching whereIn conditions:

findWhereNotIn()

The findWhereNotIn method finds all entities matching whereNotIn conditions:

Notes:

  • Signature of all of the findWhere, findWhereIn, and findWhereNotIn methods has been changed since v2.0.0.
  • All of the findWhere, findWhereIn, and findWhereNotIn methods utilize the where, whereIn, and whereNotIn methods respectively, and thus takes first argument as an array of same parameters required by the later ones.

create()

The create method creates a new entity with the given attributes:

update()

The update method updates an entity with the given attributes:

delete()

The delete method deletes an entity with the given id:

Notes:

  • All find* methods take one more optional parameter for selected attributes.
  • All set* methods returns an instance of the current repository, and thus can be chained.
  • create, update, and delete methods always return an array with two values, the first is action status whether it's success or fail as a boolean value, and the other is an instance of the model just operated upon.
  • It's recommended to set IoC container instance, repository model, and repository identifier explicitly through your repository constructor like the above example, but this package is smart enough to guess any missing requirements. Check Automatic Guessing Section

Code To An Interface

As a best practice, it's recommended to code for an interface, specifically for scalable projects. The following example explains how to do so.

First, create an interface (abstract) for every entity you've:

Second, create a repository (concrete implementation) for every entity you've:

Now in a Laravel Service Provider bind both to the IoC (inside the register method):

This way we don't have to instantiate the repository manually, and it's easy to switch between multiple implementations. The IoC Container will take care of the required dependencies.

Note: Checkout Laravel's Service Providers and Service Container documentation for further details.

Add Custom Implementation

Since we're focusing on abstracting the data layer, and we're separating the abstract interface from the concrete implementation, it's easy to add your own implementation.

Say your domain model uses a web service, or a filesystem data store as it's data source, all you need to do is just extend the BaseRepository class, that's it. See:

EloquentRepository Fired Events

Repositories fire events at every action, like create, update, delete. All fired events are prefixed with repository's identifier (you set before in your repository's constructor) like the following example:

For your convenience, the events suffixed with .entity.created, .entity.updated, or .entity.deleted have listeners that take actions accordingly. Usually we need to flush cache -if enabled & exists- upon every success action.

There's one more event rinvex.repository.uniqueid.entity.cache.flushed that's fired on cache flush. It has no listeners by default, but you may need to listen to it if you've model relations for further actions.

Mandatory Repository Conventions

Here some conventions important to know while using this package. This package adheres to best practices trying to make development easier for web artisans, and thus it has some conventions for standardization and interoperability.

Note: Rinvex Repository adheres to PSR-4: Autoloader and expects other packages that uses it to adhere to the same standard as well. It's required for Automatic Guessing, such as when repository model is missing, it will be guessed automatically and resolved accordingly, and while that full directory structure might not required, it's the standard for all Rinvex packages.

Automatic Guessing

While it's recommended to explicitly set IoC container, repository identifier, and repository model; This package is smart enough to guess any of these required data whenever missing.

Flexible & Granular Caching

Rinvex Repository has a powerful, yet simple and granular caching system, that handles almost every edge case. While you can enable/disable your application's cache as a whole, you have the flexibility to enable/disable cache granularly for every individual query! That gives you the ability to except certain queries from being cached even if the method is normally cached by default or otherwise.

Let's see what caching levels we can control:

Whole Application Cache

Checkout Laravel's Cache documentation for more details.

Individual Query Cache

Change cache per query or disable it:

Change cache driver per query:

Both setCacheLifetime & setCacheDriver methods are chainable:

Unless disabled explicitly, cache is enabled for all repositories by default, and kept for as long as your rinvex.repository.cache.lifetime config value, using default application's cache driver cache.default (which could be changed per query as well).

Caching results is totally up to you, while all retrieval find* methods have cache enabled by default, you can enable/disable cache for individual queries or control how it's being cached, for how long, and using which driver as you wish.

Temporary Skip Individual HTTP Request Cache

Lastly, you can skip cache for an individual request by passing the following query string in your URL skipCache=true. You can modify this parameter to whatever name you may need through the rinvex.repository.cache.skip_uri config option.

Final Thoughts

Changelog

Refer to the Changelog for a full history of the project.

Support

The following support channels are available at your fingertips:

Contributing & Protocols

Thank you for considering contributing to this project! The contribution guide can be found in CONTRIBUTING.md.

Bug reports, feature requests, and pull requests are very welcome.

Security Vulnerabilities

If you discover a security vulnerability within this project, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.

About Rinvex

Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity.

License

This software is released under The MIT License (MIT).

(c) 2016 Rinvex LLC, Some rights reserved.


All versions of repository with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
illuminate/events Version 5.1.*|5.2.*|5.3.*
illuminate/support Version 5.1.*|5.2.*|5.3.*
illuminate/database Version 5.1.*|5.2.*|5.3.*
illuminate/container Version 5.1.*|5.2.*|5.3.*
illuminate/contracts Version 5.1.*|5.2.*|5.3.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rinvex/repository contains the following files

Loading the files please wait ....