New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

taylornetwork/laravel-repository

A repository service provider to dynamically bind all existing repositories in app.
58 1
Install
composer require taylornetwork/laravel-repository
Latest Version:1.3.0
PHP:>=7.0.0
Laravel:5
Last Updated:Sep 20, 2017
Links: GitHub  ·  Packagist
Maintainer: samueljtaylor

Repositories for Laravel

An easy and customizable to create repositories that will be automatically registered for you.

Install

Via Composer

$ composer require taylornetwork/laravel-repository

Setup

Add the service provider to the providers array in config/app.php

'providers' => [
	
	TaylorNetwork\LaravelRepository\RepositoryServiceProvider::class,
	
],

Publish Config

$ php artisan vendor:publish

Will add repository.php to your config directory.

Usage

The service provider will automatically bind repositories to their contracts based on the settings in config/repository.php

Defaults

By default Repositories are stored in App\Repositories\ModelName where ModelName is the name of the model the repository will handle.

The default naming convention used is ModelNameRepository for the contract and EloquentModelName for the class.

Commands

make:repository

This package adds the artisan command repository:generate to create the repository pattern based on settings in config/repository.php

To create a repository for the User model

$ php artisan repository:generate User

Will create

- ProjectRoot
	- app
		- Repositories
			- User
				- UserRepository.php
				- EloquentUser.php

If you are using a driver other than Eloquent you can specify using the --driver option

$ php artisan repository:generate User --driver=storage

Will create

- ProjectRoot
	- app
		- Repositories
			- User
				- UserRepository.php
				- StorageUser.php

Note: If you plan on using other drivers add them to the drivers array in config/repository.php, the service provider will search for the class in the order of the array.

make:repositoryClass

Same as repository:generate but will only create the class, no contract.

$ php artisan repository:class User --driver=storage

Creates app/Repositories/User/StorageUser.php

make:repositoryContract

Same as repository:generate but will only create the contract, no class.

$ php artisan repository:contract User 

Creates app/Repositories/User/UserRepository.php

Note: This command does not accept the --driver option.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

407,699,310 4,663

Version History

Version Released PHP Laravel License
1.3.0 >=7.0.0 5.5.*
1.2.0 >=5.4.0 ^5.4
1.1.0 >=5.4.0 ^5.4
1.0.0 >=5.4.0 ^5.3