detatech / repository-pattern
Repository Pattern For Laravel >= 5.1.* | >= 5.2.* | >= 5.3.*
1.0.0
2016-08-26 10:23 UTC
Requires
- php: ~5.5|~5.6|~7.0
- illuminate/console: ~5.1.0|~5.2.0|~5.3.0
- illuminate/filesystem: ~5.1.20|~5.2.0|~5.3.0
- illuminate/support: ~5.1.0|~5.2.0|~5.3.0
Requires (Dev)
- phpunit/phpunit: 5.5.*
This package is not auto-updated.
Last update: 2024-09-26 03:09:10 UTC
README
使用单条命令创建Repository Pattern文件。
用法
- 使用composer要求此包
composer require detatech/repository-pattern:1.0.*
- 更新
config/app.php
中的$providers
数组
$providers = [
// ... other serivce providers
DetaTech\RepositoryPattern\RepositoryPatternServiceProvider::class,
];
- 发布默认配置(可选)
$ php artisan vendor:publish
现在您可以在artisan列表中查看已列出命令repository:create
。使用以下命令查看
$ php artisan list
创建文件后,您需要将其绑定到应用程序的IoC容器中。为此,打开providers/AppServiceProvider
,在register
方法中粘贴以下代码
$repositoryFileNames = [
// Whatever file name that you give while creating the file from
// the terminal that same name should come here in single quotes(')
];
foreach ($repositoryFileNames as $key => $fileName) {
// Notice the namespace..
// Keep it default if you have not changed it,
// Else, update the word _App_ with your application's namespace.
$this->app->bind(
"App\\Repositories\\Contracts\\{$fileName}Contract", "App\\Repositories\\Classes\\{$fileName}"
);
}
未能完成以上步骤将导致异常
Target [/path/to/Contract/File] is not instantiable
完成。
许可证
此包是开源软件,受MIT许可证许可。