Download the PHP package noitran/micro-repositories without Composer
On this page you can find all versions of the php package noitran/micro-repositories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download noitran/micro-repositories
More information about noitran/micro-repositories
Files in noitran/micro-repositories
Package micro-repositories
Short Description Repositories package for laravel / lumen projects
License LGPL-3.0
Informations about the package micro-repositories
MicroRepositories
About
- Package adds support to work with Repository Design pattern in laravel and lumen applications. Package was created from scratch as other versions of repository pattern packages were unmaintained or poor quality. Contributions are welcome!
Install
- Install as composer package
Laravel
- Laravel uses provider auto discovery. Config file can be published using command
Lumen
-
Open your bootstrap/app.php and register as service provider
- Config file should be loaded manually in bootstrap/app.php
Repositories
Creating Eloquent model
- Create Eloquent model like you do it initially. Using laravel generators or manually. Example model what I will use:
Creating Eloquent Repository implementation and Repository Interface
-
First let's create Interface of our Repository
-
Second step will be to create implementation of Repository Interface. We will extend
SqlRepository
which adds support for querying with table names. If you usejenssegers/laravel-mongodb
package, then your repository implementation should extendMongoRepository
class - After Repository and Interface were created, they should be loaded using laravel IoC binding. Fastest way to do it is to add binding into
App\Providers\AppServiceProvider
class.
Filters
-
Filters are sitting on top of Repositories and uses Criteria to enable query filtering abilities with built in and / or custom Criteria.
-
Creating filter class is easy. Example:
- After creating UserFilter you are now able to use built in Filtering Criteria and add your custom. Filters acts as layer between HTTP Requests and Repositories giving you ability to use RQL (Request Query Language), ordering, sorting and pagination capabilities out of the box.
Criteria
@todo