定制 alexmanno/pipeline-remix 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alexmanno/pipeline-remix

Composer 安装命令:

composer require alexmanno/pipeline-remix

包简介

Reinvented pipelines for PHP

README 文档

README

Reinvented pipelines for PHP

Latest Stable Version Latest Unstable Version GitHub license composer.lock available Scrutinizer Code Quality Code Coverage Build Status

What's a Pipeline

A pipeline is a set of data processing elements connected in series, where the output of one element is the input of the next one.

Installation

From Composer

To use this package, use Composer:

  • from CLI: composer require alexmanno/pipeline-remix
  • or, directly in your composer.json:
{
    "require": {
        "alexmanno/pipeline-remix": "dev-master"
    }
}

Architecture

Pipeline

A Pipeline is a simple SplQueue of Stage.

You can initialize it in this way: $pipeline = new AlexManno\Remix\Pipelines\Pipeline();

You can add Stage to Pipeline using $pipeline->pipe($stage)

Stage

A Stage is an object that implements AlexManno\Remix\Pipelines\Interfaces\StageInterface and has an __invoke() method.

This object is the smallest part of the pipeline and it should be a single operation.

You can create a class that implements that interface.

Ex.

 class MyCoolStage implements AlexManno\Remix\Pipelines\Interfaces\StageInterface
 {
    /**
     * @param Payload $payload
     */
    public function __invoke(Payload $payload)
    {
        $payload->setData('Hello!');
        
        return $payload;
    }
}

Payload

Payload is an object that implements PayloadInterface and can store any kind of data. For example in a web application it can store Request and Response.

Ex.

class Payload implements AlexManno\Remix\Pipelines\Interfaces\PayloadInterface
{
    /** @var RequestInterface */
    public $request;
    /** @var ResponseInterface */
    public $response;
}

Compose and run your pipeline

If you have already initialized Payload object and Stages objects you can compose your pipeline.

Ex.

// -- Initialized objects: $payload, $pipeline, $stage1, $stage2 --

$pipeline
    ->pipe($stage1) // Add $stage1 to queue
    ->pipe($stage2); // Add $stage2 to queue

$pipeline($payload);  // Run pipeline: invoke $stage1 and then $stage2 with payload from $stage1

You can also compose two or more pipelines together using method add()

Ex.

// -- Initialized objects: $payload, $pipeline1, $pipeline2, $stage1, $stage2 --

$pipeline1->pipe($stage1); // Add $stage1 to $pipeline1
$pipeline2->pipe($stage2); // Add $stage2 to $pipeline2

$pipeline1->add($pipeline2); // Add stages from $pipeline2

$payload = $pipeline1($payload); // Run pipeline: invoke $stage1 (from $pipeline1) and then $stage2 (from $pipeline2) with payload from $stage1

Examples

Conclusion

I hope you found useful this repo. Thanks for attention.

Made with ❤️ by @alexmanno

alexmanno/pipeline-remix 适用场景与选型建议

alexmanno/pipeline-remix 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 11 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 alexmanno/pipeline-remix 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alexmanno/pipeline-remix 我们能提供哪些服务?
定制开发 / 二次开发

基于 alexmanno/pipeline-remix 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-24