承接 maxiviper117/result-flow 相关项目开发

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

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

maxiviper117/result-flow

最新稳定版本:v1.3.0

Composer 安装命令:

composer require maxiviper117/result-flow

包简介

A minimal Result type with branch-aware chaining for PHP

README 文档

README

run-tests PHPStan License: MIT

Minimal, type-safe Result monad for explicit success/failure handling in PHP.

Primary class: Maxiviper117\ResultFlow\Result (see src/Result.php)

Why

  • Keep success and failure paths explicit
  • Chain actions fluently with metadata propagation
  • Convert exceptions to failures automatically
  • Small surface area with PHPStan-friendly templates

Installation

composer require maxiviper117/result-flow

Import and use:

use Maxiviper117\ResultFlow\Result;

Laravel config publish (optional)

The package is framework-agnostic, but if you're using Laravel the service provider is auto-discovered. Publish the config to override debug sanitization settings (redaction token, sensitive keys, max string length):

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

Edit config/result-flow.php to match your policies. Keys include enabled, redaction, sensitive_keys, max_string_length, and truncate_strings. Result::toDebugArray() will pick up these values via the config() helper when present.

Quick Start

$result = Result::ok($payload)
    ->then(new ValidateOrder)              // runs on success
    ->then(fn($data, $meta) => save($data))
    ->otherwise(fn($error, $meta) => cacheFallback($error, $meta));

// Handle both branches
return $result->match(
    onSuccess: fn($value) => response()->json($value),
    onFailure: fn($error) => response()->json(['error' => $error], 400),
);

Documentation

The full guide, API reference, patterns, and testing notes are available at https://maxiviper117.github.io/result-flow/result/.

Contributing

See CONTRIBUTING.md for setup, checks, and PR expectations.

Testing

composer test

License

The MIT License (MIT). Please see LICENSE.md for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-09