承接 crixuamg/laravel-decorators 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

crixuamg/laravel-decorators

最新稳定版本:9.0.0-beta-13

Composer 安装命令:

composer require crixuamg/laravel-decorators

包简介

README 文档

README

Latest Stable Version Latest Unstable Version Total Downloads

About
Installation
Usage
Customization
Commands

Installation

Put the following in your composer.json file:

    "require": {
        "crixuamg/laravel-decorators": "^6.0.0",
        // ...
    }

Usage

After publishing the config file, register your decorators as shown in the bottom of the file. Then extend the AbstractController in a controller and call $this->setup() in the __construct() using the key created in the config file.

Example:\
UserController

```php
use \CrixuAMG\Decorators\Http\Controllers\AbstractController;

class UserController extends AbstractController {
    public function __construct()
    {
        $this->setup('users', UserResource::class);
    }

    public function index() {
       return $this->forwardResourceful(__FUNCTION__);
    }
 }
```
And put the following in
config/decorators.php

```php
    'tree' => [
        'users'                => [
            'contract'  => App\Contracts\UserContract::class,
            'arguments' => [
                // First element is the deepest layer
                App\Repositories\UserRepository::class,
                App\Caches\UserCache::class,
                App\Decorators\UserDecorator::class,
            ],
        ],
    ]
```

When hitting the route linked to the index method the application will go through the UserDecorator, UserCache and UserRepository. Then it will go back through the same classes, passing the returned data and performing the required actions, like caching and firing events. After everything has been processed the data will be returned using the resource as stated in the __construct.

Customization

You can set an enabled flag within the config/decorators.php file. When this is set to false, any decorators implementing the CrixuAMG\Decorators\Caches\AbstractCache class will be ignored.

Commands

To make development even faster and easier, some commands have been created to improve ease of use.

    php artisan decorator:cache      ModelCache
    php artisan decorator:repository ModelRepository
    php artisan decorator:contract   ModelContract

Or, create all three in a single command:

    php artisan decorators:make User

For your convenience, a command has been included that automatically creates the following:

  • Model
  • Controller
  • Contract
  • Cache
  • Repository
  • Resource
    php artisan decorators:starter User

The following options can be used to create extra files:

  • -m Creates a migration
  • -d Creates a decorator
  • -r Creates 4 request classes (Show, Store, Update, Delete) in app/Http/Requests/<MODEL_NAME>/

统计信息

  • 总下载量: 8.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固