ahmedmahmoud/repository-pattern
最新稳定版本:5.0.0
Composer 安装命令:
composer require ahmedmahmoud/repository-pattern
包简介
A Laravel package to implement the Repository Pattern
README 文档
README
This 'Package' support only api A powerful package to automatically generate the complete repository pattern structure for your Laravel applications.
Features
- 🚀 Auto-generates all repository pattern components with one command
- 📦 Includes: Model, Repository, Service, Controller, Form Requests, Migration
- 🔄 Supports both API
- ⚡ Easily extendable base classes
- 🔧 Customizable stubs
Installation
- Require the package via Composer:
composer require ahmedmahmoud/repository-pattern
2.(Optional) Publish stubs for customization:
php artisan vendor:publish --tag=repository-stubs --force
- Run the setup command to install base files:
php artisan repository:setup
- Generate complete structure for a new model:
php artisan make:repo {name : The name of the repository} --all (Includes: Model, Repository, Service, Controller, Form Requests, Migration}
🧩 Dependency Injection Binding
The package automatically registers repository bindings in the service container:
$this->app->when(ProductService::class) ->needs(RepositoryInterface::class) ->give(ProductRepository::class);
if you not install api this return in your terminal
out when installed api then try this command again
php artisan make:repo student --all Created migration file for students table. Cannot write to C:\xampp_new\htdocs\first_package\routes/api.php. Please manually add the following to routes/api.php: use Illuminate\Support\Facades\Route; use App\Http\Controllers\StudentController; Route::resource('students', StudentController::class); Repository pattern files for Student created successfully!
How it works:
- when(): Specifies the service class that needs dependency
- needs(): Defines the interface/abstract type needed
- give(): Provides the concrete implementation
You can find these bindings in:
app/Providers/RepositoriesServiceProvider.php
And File
bootstrap/providers/RepositoriesServiceProvider.php
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-23