Laravel 5.5 repository generator.
composer require ozankurt/repoist
Add the service provider to config/app.php
.
/*
* Package Service Providers...
*/
Kurt\Repoist\RepoistServiceProvider::class,
In Laravel: Run php artisan vendor:publish --tag=repoist-config
from the console to configure the Repoist according to your needs.
You're all set. Run php artisan
from the console, and you'll see the new commands.
php artisan make:repository Task
Will output:
app/Contracts/Task/TaskRepository.php
(contract)app/Repositories/Eloquent/EloquentTaskRepository.php
app/Task.php
(if needed)
php artisan make:criterion Completed
Will output:
app/Repositories/Eloquent/Criteria/Completed.php
If somehow you cannot publish the config/repoist.php
from artisan here you can copy and use it.
<?php
return [
/**
* Namespaces are being prefixed with the applications base namespace.
*/
'namespaces' => [
'contracts' => 'Repositories\Contracts',
'repositories' => 'Repositories\Eloquent',
],
/**
* Paths will be used with the `app_path()` function to reach app directory.
*/
'paths' => [
'contracts' => 'Repositories/Contracts/',
'repositories' => 'Repositories/Eloquent/',
],
];