定制 wpstarter/flow 二次开发

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

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

wpstarter/flow

Composer 安装命令:

composer require wpstarter/flow

包简介

A library for handling workflow automation and process management seamlessly.

README 文档

README

Flow package for WpStarter or Laravel framework that provides a fluent interface for handling workflow and process management.

Requirements

  • PHP 7.4 or higher
  • WpStarter/Laravel framework
  • Composer

Installation

You can install the package via composer:

composer require wpstarter/flow

Configuration

You can publish the configuration file using:

php artisan vendor:publish --tag=flow-config

Usage

Create Flow class extends WpStarter\Flow\Flow

namespace App\Flow\Flows;

use WpStarter\Flow\Flow;
use WpStarter\Flow\FlowRequest;
use App\Flow\Flows\OrderFlow;

class LoginFlow extends Flow{
    function handle(FlowRequest $request){
        // TODO: Implement handle() method.
        if($this->state('is_logged_in')){
            $this->redirect(OrderFlow::class);
            return ['success'=>true];
        }else{
            if(Auth::check($request['user'],$request['pass'])){
                $this->state('is_logged_in',true);
                $this->redirect(OrderFlow::class);
                return ['success'=>true];
            }else{
                return ['success'=>false,'message'=>'invalid credentials'];
            }
        }
    }
}

Flow state management

Go to next flow

    $this->redirect(NextFlowClass::class)

Go to previous flow

    $this->back()

Redirect to default flow

    $this->redirectToDefault()

Flow Providers

Create App\Flow\MyFlowProvider extends WpStarter\Flow\Support

class MyFlowProvider extends FlowProvider
{
    public function register()
    {
        $this->flows->register(LoginFlow::class);
        $this->flows->register(OrderFlow::class);
        $this->loadRoutesFrom( __DIR__ . '/routes.php');
    }
}

Add MyFlowProvider to config/flow.php

<?php
return [
    'providers'=>[
        App\Flow\MyFlowProvider::class
    ]
];

Flow Routes

Simple matching

use \WpStarter\Flow\Support\Facades\Route;

//Run login flow when received message /login
Route::match('/login',LoginFlow::class);
//Run order flow when received message /order or /buy
Route::match(['/order','/buy'],OrderFlow::class);

Advanced matching

use \WpStarter\Flow\Support\Facades\Route;

//Run login flow when `secret_login` is 'Abcd1234'
Route::match(function(\WpStarter\Flow\FlowRequest $request){
    if($request->get('secret_login')==='Abcd1234'){
        return true;
    }
},LoginFlow::class);

Auto register route in Flow

Route can be registered automatically by define $route property in Flow class

class LoginFlow extends Flow{
    protected $route='logmein';
}

Above code will register following route

Route::match('logmein',LoginFlow::class);

Run Flow

Create Flow Request

You can create a flow request based on current http request. Normally FlowRequest required to have 2 attributes: id and message. We compare route against message to find matched flow

use WpStarter\Flow\FlowRequest;
$flowRequest=new FlowRequest([
    'id'=>$request['phone_number'],
    'message'=>$request->input('message'),
]);

Run flow in a controller

namespace App\Http\Controllers;
use WpStarter\Flow\FlowManager;
use Illuminate\Http\Request;
class FlowController{
    function index(FlowManager $flowManager, Request $request){
        $flowRequest=new FlowRequest([
            'id'=>Auth::id(),
            'message'=>$request->input('message'),
        ]);
        return $flowManager->run($flowRequest);
    }
}

License

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

wpstarter/flow 适用场景与选型建议

wpstarter/flow 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 430 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 wpstarter/flow 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-10