An abstraction layer that let's you implement repository pattern for your models.
unostentatious/repository is a Laravel package for an abstraction layer that let's you implement repository pattern for your models..
It currently has 0 GitHub stars and 18 downloads on Packagist (latest version v1.3.1).
Install it with composer require unostentatious/repository.
Discover more Laravel packages by unostentatious
or browse all Laravel packages to compare alternatives.
Last updated
An abstraction layer that let's you implement repository pattern for your models.
composer require unostentatious/repository
Laravel, edit config\app.php and add the provider under package service provider section: /*
* Package Service Providers...
*/
\Unostentatious\Repository\Integration\Laravel\UnostentatiousRepositoryProvider::class,
Laravel app's root directory, publish the vendor:php artisan vendor:publish --provider="Unostentatious\Repository\Integration\Laravel\UnostentatiousRepositoryProvider"
unostent-repository.php config file from vendor/unostentatious/repository/Integration/config/ directory{root}/config/ directory is not existing in your Lumen app, make sure to create it first, paste the config file you just copiedbootstrap/app.php then register the service provider and add the package's config explicitly like so:// Other actions...
$app->register(\Unostentatious\Repository\Integration\Laravel\UnostentatiousRepositoryProvider::class);
$app->configure('unostent-repository');
Right now the package's configuration is already residing to your app's config directory /config,
there are 3 values in the package's config that you can customize to fit your needs:
<?php
declare(strict_types=1);
return [
'root' => null,
'destination' => null,
'placeholder' => null
];
| Key | Value
| -------------------------------------- | ---------------------------------------------------------------------
| root | The base directory in which the application is assigned the folder,
| | and the structure of the repositories where will be based on.
| | sample value:
| | - Laravel: \app_path()
| | - Lumen: \base_path() . '/app'
| |
| destination | Define the repositories destination within the {root} directory.
| | sample value:
| | - 'Database'
| |
| | When a value is given ie Database the default path will be:
| | {root}/Database/{placeholder} | | | **placeholder** | Define the repositories placeholder within the {root}/{destination}, | | sample value: | | - Repo | | when a value is given ie Repo the default path will be: | |{root}/{destination}/Repo. | | | | The default value is null, which makes the folder structure into: | | {root}/{destination}/Repositories`
Viola! Just like that your ready to use Unostentatious Repository in your Laravel or Lumen application, happy coding!
When creating the repository classes it MUST reside on the specified path {root}/{destination}/{placeholder},
where in this case the default path will be app/Database/Repositories:
It must be composed of a concrete class, and it's corresponding interface.
Then the concrete class MUST extend the AbstractEloquentRepository from the package.
See the example:
<?php
namespace App\Database\Repositories;
use App\Database\Repositories\Interfaces\UserRepositoryInterface;
use Unostentatious\Repository\AbstractEloquentRepository;
class UserRepository extends AbstractEloquentRepository implements UserRepositoryInterface
{
// Business logic goes here.
}
Then after these classes has been written, just execute composer dump-autoload to invoke the IoC and these classes will now be injectable to consuming classes ie: Controllers.