承接 czim/laravel-processor 相关项目开发

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

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

czim/laravel-processor

Composer 安装命令:

composer require czim/laravel-processor

包简介

Pipelined processor framework for Laravel.

README 文档

README

Latest Version on Packagist Software License Build Status Latest Stable Version SensioLabsInsight

Framework for building modular, pipelined data processors.

The idea behind this is to have a configurable, clean and testable setup for complex data processing. It carries a lot of overhead, of course, so this only makes sense for fairly demanding (background) processing.

Usage example: This was constructed to better handle extensive product and debtor datasheet imports for a particular project. The imported data is converted to a relational database structure spanning many tables. Using pipelined processing, this can be done in discrete, separately testable process step classes that each have their own responsibility.

Install

Via Composer

$ composer require czim/laravel-processor

Usage

Extend Czim\PipelineProcessor (or Czim\AbstractProcessor) and write implementations for the abstract methods.

Processing is done by calling the process() method on your class. The parameter for this method must be an implementation of Czim\DataObject\Contracts\DataObjectInterface (see the czim\laravel-dataobject for more information).

    
    $processor = new Your\Processor();

    $data = new Your\DataObject($someData);
    
    $result = $processor->process($data);
    
    if ( ! $result->success) {
        ...
    }

The returned result is an instance of Czim\Processor\DataObjects\ProcessorResult. This is a DataObject with a boolean success property, as well as warnings and errors MessageBags by default.

Pipeline Processor

A pipeline processor consists of a series of process steps, which are executed in sequence.

A process context is passed into the pipeline and from step to step. It contains the data to be processed, cache, settings and such and its contents may be modified to affect the way subsequent steps behave.

When exceptions are thrown, the pipeline ends and the remaining steps are not executed.

To use it, extend Czim\PipelineProcessor and add the following to your class:

    /**
     * @return array
     */
    protected function processSteps()
    {
        // Set a series of process step classnames and return it
        // these steps must extend Czim\Processor\Steps\AbstractProcessStep
        // or otherwise implement Czim\Processor\Contracts\ProcessStepInterface
        return [
            Your\ProcessSteps\ClassNameHere::class,
            Your\ProcessSteps\AnotherClassNameHere::class,
        ];
    }

For more configuration options, see the PipelineProcessor source.

Process Steps

Process steps can extend Czim\Processor\Steps\AbstractProcessStep and implement the process() method:

    protected function process()
    {
        // Define your custom processing here.
        // The data object can be accessed through $this->data
        // and the process context through $this->context
    }

Process Context

A ProcessContext is an instance that represents the context in which the pipeline steps take place. It stores the data passed into the process() method. It can also store settings and a cache.

A ContextRepositoryTrait for your own extensions is also provided, in case you want to store repositories with the czim\laravel-repository package in the context.

Database Transaction

By default, the (main) pipeline is executed in a database transaction; it is comitted on succesfully completing all the steps, and rolled back on any exception thrown.

To run the process without a database transaction, set the following property in your PipelineProcessor extension:

    protected $databaseTransaction = false;

Simple Processor

If a pipeline is overkill, you can also use a simpler approach.

Extend Czim\AbstractProcessor and add the following to your class:

    protected function doProcessing()
    {
        // Define your custom processing here.
        // The data object can be accessed through $this->data
        
        // The result data object that will be returned can
        // be modified through $this->result
    }

For more configuration options, see the AbstractProcessor source.

To Do

  • Make App/Container injectable, remove dependency on laravel's app() function

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

czim/laravel-processor 适用场景与选型建议

czim/laravel-processor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.15k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「pipeline」 「processor」 「data processing」 「modular processing」 「process step」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 czim/laravel-processor 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-02