derakht/repository-pattern 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

derakht/repository-pattern

Composer 安装命令:

composer require derakht/repository-pattern

包简介

Implement repository pattern design with a command

README 文档

README

Generate repository structure with single command

This package generates repository pattern files related to a model to use them in your app.

Installation

Require this package with composer using the following command:

composer require derakht/repository-pattern

Configuration

Publish the configuration file with th following command.

php artisan vendor:publish --provider="Derakht\RepositoryPattern\RepositoryPatternServiceProvider"

You can change default paths in this file.

Usage

You can now run the below command to create repository files.

php artisan make:repository ModelName

Example

php artisan make:repository Post

PostController.php

<?php

namespace App\Http\Controllers;

use App\Repositories\Contract\PostRepositoryInterface;

class PostController extends Controller
{
    public $postRepository;

    public function __construct()
    {
        $this->postRepository = app(PostRepositoryInterface::class);
    }

    public function index()
    {
        return $this->postRepository->all();    
    }
}

or if you want to use injection add App\Providers\RepositoryServiceProvider::class to provider array in config/app.php.

PostController.php

<?php

namespace App\Http\Controllers;

use App\Repositories\Contract\PostRepositoryInterface;

class ReportController extends Controller
{
    public $postRepository;

    public function __construct(PostRepositoryInterface $postRepository)
    {
        $this->postRepository = $postRepository;
    }

    public function index()
    {
        return $this->postRepository->all();    
    }
}

统计信息

  • 总下载量: 66
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固