jason-guru/laravel-make-repository
Composer 安装命令:
composer require jason-guru/laravel-make-repository
包简介
A simple package to create a make:repository command for Laravel 10, 11, and 12.
README 文档
README
A simple package that adds a php artisan make:repository command to Laravel 10, 11, 12, and 13.
Installation
Require the package with composer:
composer require jason-guru/laravel-make-repository --dev
Or add it to your composer.json require-dev section and run composer update:
"require-dev": { "jason-guru/laravel-make-repository": "^1.0" }
Usage
php artisan make:repository your-repository-name
Example:
php artisan make:repository UserRepository
Or with a sub-namespace:
php artisan make:repository Backend\\UserRepository
Wire up a model in one shot with the --model (-m) option — the generated repository imports the model and returns it from model():
php artisan make:repository UserRepository --model=User
The above commands create a Repositories directory inside the app directory.
Generated files
By default, make:repository UserRepository creates two files:
app/Repositories/UserRepository.php— the concrete classapp/Repositories/Contracts/UserRepositoryInterface.php— the paired interface (extendsRepositoryContract)
The concrete is declared implements UserRepositoryInterface, and the package's service provider auto-binds the interface to the concrete in the container — so you can type-hint the interface anywhere:
public function __construct(private UserRepositoryInterface $users) {}
To skip the interface for a single command, pass --no-interface:
php artisan make:repository UserRepository --no-interface
Configuration
Publish the config to customize behavior:
php artisan vendor:publish --tag=repository-config
That creates config/repository.php:
return [ 'path' => 'app/Repositories', 'namespace' => 'App\\Repositories', 'with_interface' => true, // generate a paired interface 'bind' => true, // auto-bind interface => concrete ];
Example output
A repository generated with --model=User looks like this:
<?php namespace App\Repositories; use App\Models\User; use App\Repositories\Contracts\UserRepositoryInterface; use JasonGuru\LaravelMakeRepository\Repository\BaseRepository; class UserRepository extends BaseRepository implements UserRepositoryInterface { public function model(): string { return User::class; } }
jason-guru/laravel-make-repository 适用场景与选型建议
jason-guru/laravel-make-repository 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 316.95k 次下载、GitHub Stars 达 62, 最近一次更新时间为 2018 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「repository」 「command」 「laravel」 「make」 「eloquent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jason-guru/laravel-make-repository 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jason-guru/laravel-make-repository 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jason-guru/laravel-make-repository 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Wrapper for exec and it's results
repository php library
Symfony bundle to monitor and execute commands
Shell command module for PHP.
Library with classes to help you do batch.
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 316.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 65
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-28