net_bazzline/php_component_process_pipe 问题修复 & 功能扩展

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

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

net_bazzline/php_component_process_pipe

最新稳定版本:1.1.1

Composer 安装命令:

composer require net_bazzline/php_component_process_pipe

包简介

free as in freedom php component process to easy up creation of pipe process in php

README 文档

README

This free as in freedom component ease up creation of a pipe for processes in php.

Indeed, it is a pseudo pipeline (process collection or process batch) since the php process is single threaded so far.

Currently, there is no plan to bloat the code base with an implementation of STDIN, STDOUT or STDERR. Errors can be handled by the thrown exception. Input is defined by the ExecutableInterface, as well as the output (return value).

The build status of the current master branch is tracked by Travis CI: Build Status Latest stable

The scrutinizer status are: code quality

The versioneye status is: dependencies

Downloads: Downloads this Month

It is also available at openhub.net.

Changelog can be found here.

Why?

  • separate complex operations into simpler
  • easy up unit testing for smaller processes
  • separate responsibility (data generator/transformer/validator/flow manipulator)
  • create process chains you can read in the code (separate integration code from operation code)
  • no dependencies (except you want to join the development team)

Examples

Install

By Hand

mkdir -p vendor/net_bazzline/php_component_process_pipe
cd vendor/net_bazzline/php_component_process_pipe
git clone https://github.com/bazzline/php_component_process_pipe

With Packagist

composer require net_bazzline/php_component_process_pipe:dev-master

Usage

By using the pipe method for multiple process

use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;

try {
    $pipe = new Pipe();
    
    $pipe->pipe(
        new ProcessOne(), 
        new ProcessTwo()
    );
    
    $output = $pipe->execute($input);
} catch (ExecutableException) {
    //handle process exception
} catch (InvalidArgumentException) {
    //handle pipe exception
}

By using the pipe method once for each process

use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;

try {
    $pipe = new Pipe();
    
    $pipe->pipe(new ProcessOne());
    $pipe->pipe(new ProcessTwo());
    
    $output = $pipe->execute($input);
} catch (ExecutableException) {
    //handle process exception
} catch (InvalidArgumentException) {
    //handle pipe exception
}

By instantiation

use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;

try {
    $pipe = new Pipe(
        new ProcessOne(),
        new ProcessTwo()
    );
    
    $output = $pipe->execute($input);
} catch (ExecutableException) {
    //handle process exception
} catch (InvalidArgumentException) {
    //handle pipe exception
}

By doing all

use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;

try {
    $pipe = new Pipe(
        new ProcessOne(),
        new ProcessTwo()
    );
    
    $pipe->pipe(new ProcessThree());
    $pipe->pipe(
        new ProcessFour(),
        new ProcessFive()
    );

    $output = $pipe->execute($input);
} catch (ExecutableException) {
    //handle process exception
} catch (InvalidArgumentException) {
    //handle pipe exception
}

API

API is available at bazzline.net.

Development notes

After code changes, please run:

composer check
./vendor/bin/rector process
./vendor/bin/php-cs-fixer fix example
./vendor/bin/php-cs-fixer fix source
./vendor/bin/php-cs-fixer fix test

Links

Thanks to

Other pipe implementations

Final Words

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-].

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPLv3
  • 更新时间: 2014-11-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固