bamiz/use-case-executor-bundle 问题修复 & 功能扩展

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

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

bamiz/use-case-executor-bundle

Composer 安装命令:

composer require bamiz/use-case-executor-bundle

包简介

A Symfony Bundle that provides tools facilitating the isolation of business logic of your application from the delivery mechanisms.

README 文档

README

Use Case Executor Bundle is a Symfony bundle providing an example implementation of Screaming Architecture, with help of components that come with Symfony framework. It encourages designing your class in a fashion that reflects the intention of your application. The tools provided by Use Case Executor Bundle relieve you of the repetitive task of extracting the information required to perform the right behavior from the application input, which helps you output the results in the desired way.

Installation

Just run

$ composer require bamiz/use-case-executor-bundle

Configuration

Register your bundle in AppKernel.php:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Bamiz\UseCaseExecutorBundle\BamizUseCaseExecutorBundle(),
        );

        // ...
    }

    // ...
}

Enable serializer in app/config.yml:

# app/config.yml

framework:
    serializer: ~
    

Basic usage

Register your Use Case as a Symfony service:

# app/services.yml

app.my_use_case:
    class: AppBundle\UseCase\MyUseCase

Using an annotation, name the Use Case and optionally assign an Input Processor and a Response Processor to it. Make sure that the Use Case class contains an execute() method with one type-hinted parameter.

<?php
// src/AppBundle/UseCase/MyUseCase.php

namespace AppBundle\UseCase;

use Bamiz\UseCaseExecutorBundle\Annotation\UseCase;

/**
 * @UseCase("My Use Case", input="http", response="json")
 */
class MyUseCase
{
    public function execute(MyUseCaseRequest $request)
    {
        // ...
    }
}

Use the Use Case Executor to execute your Use Cases:

<?php
// src/AppBundle/Controller/MyController.php

namespace AppBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class MyController extends Controller
{
    public function myAction(Request $request)
    {
        return $this->get('bamiz_use_case.executor')->execute('My Use Case', $request);
    }
}

Documentation

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固