darkwood/flow 问题修复 & 功能扩展

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

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

darkwood/flow

最新稳定版本:v1.2.5

Composer 安装命令:

composer require darkwood/flow

包简介

Flow

README 文档

README

Flow

Why ?

Flow concept aims to solve

  • Adopt asynchronous as native implementation
  • Build your code with functional programming
  • Assemble your code visually

Installation

PHP 8.5 is the minimal version to use Flow The recommended way to install it through Composer and execute

composer require darkwood/flow

Usage

<?php

use Flow\Flow\Flow;
use Flow\FlowFactory;
use Flow\Ip;

class D1 {
    public function __construct(public int $n1) {}
}

class D2 {
    public function __construct(public int $n2) {}
}

class D3 {
    public function __construct(public int $n3) {}
}

class D4 {
    public function __construct(public int $n4) {}
}

$flow = (new FlowFactory())->create(static function() {
    yield fn (D1 $data1) => new D2($data1->n1 += 1);
    yield fn (D2 $data2) => new D3($data2->n2 * 2);
    yield function(D3 $data3) {
        printf("my number %d\n", $ip->data->n3)); // display 'my number 10'

        return new D4($data3->n3);
    };
});

$ip = new Ip(new D1(4));
$flow($ip);
$flow->await();

Examples

A working script is available in the bundled examples directory

  • Run Flow : php examples/flow.php
  • Run Y-Combinator Flow : php examples/yflow.php
  • Start Server : php examples/server.php
    Start Client(s) : php examples/client.php

Documentation

https://darkwood-com.github.io/flow

License

Flow is released under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-24