Download the PHP package io-digital/repo without Composer
On this page you can find all versions of the php package io-digital/repo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download io-digital/repo
More information about io-digital/repo
Files in io-digital/repo
Package repo
Short Description Easily generate the Repository Pattern in Laravel
License MIT
Homepage https://github.com/io-digital/repo
Informations about the package repo
Repo
This package creates scaffolding to implement the Repository pattern.
Install
Repo supports package auto discovery for Laravel
composer require io-digital/repo
Add the ServiceProvider to your config/app.php providers array:
Then run the following artisan command:
This will create the following folder structure in your app/
folder:
- Models
- Concrete
- Eloquent
- _AbstractEloquentRepository.php
- Contracts
- Repositories
- _RepositoryInterface.php
- Objects
- Concrete
Note that _AbstractEloquentRepository.php and _RepositoryInterface.php are named as such to avoid existing files being overwritten. In the case of a new installation, these files can simply be renamed to AbstractEloquentRepository.php and RepositoryInterface.php, respectively. If these files already exist, on the other hand, please take care to manually merge the newly published files with the existing ones.
Usage
After installing the package the artisan command repo:create
should be available.
To create the repository structure for your object run the command:
This will create the following files:
- Models/Objects/Post.php
- Models/Contracts/Repositories/PostRepository.php
- Models/Concrete/Eloquent/EloquentPostRepository.php
It will also add the bindings in your AppServiceProvider.php
file:
Then in your Controller it's simply:
Options
-m
or--m
-c
or--c
Use the -m
option to create a migration file for your object:
Use the -c
option to create a resource controller for your object:
All together now:
The repository interface provides the following methods:
The implementations can found in Models/Concrete/AbstractEloquentRepository.php
Example usage for the find functions:
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONDUCT for details.
TODO
Clean up code
License
The MIT License (MIT). Please see License File for more information.