承接 myopensoft/runner 相关项目开发

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

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

myopensoft/runner

Composer 安装命令:

composer require myopensoft/runner

包简介

Running number manager by using database storage

README 文档

README

A Laravel package for generating sequential running numbers managed by database storage. Perfect for invoice numbers, document IDs, order numbers, and any sequential identifier with custom formatting.

Requirements

  • PHP 8.3+
  • Laravel 11.x, 12.x, 13.x

Installation

composer require myopensoft/runner
php artisan migrate

The package auto-discovers the service provider, so no manual registration is needed.

Publish Config (optional)

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

Publish Migrations (optional)

php artisan vendor:publish --tag=runner-migrations

Usage

Using the Static API

use MyOpensoft\Runner\Runner;

// First call creates a new sequence starting at 1
// Subsequent calls with the same rules increment the counter
$number = Runner::generate("{rule_1}-{p_raw,6}", "INV");
// Result: INV-000001, INV-000002, INV-000003, ...

Using the Facade

use MyOpensoft\Runner\Facades\Runner;

$number = Runner::generate("{rule_1}-{p_raw,6}", "INV");

Using the Helper Function

$number = runner()->next("{rule_1}-{p_raw,6}", "INV");

Using the Instance API

use MyOpensoft\Runner\Runner;

$runner = new Runner();

// Generate next number
$number = $runner->next("{rule_1}-{p_raw,6}", "INV");

// Peek at current counter without incrementing
$current = $runner->current("INV"); // returns int or null

// Reset a sequence
$runner->reset("INV");           // resets to 0
$runner->reset("INV", to: 100); // resets to 100

Format Placeholders

PlaceholderDescription
{rule_1} to {rule_5}Indexed rules — stored in database and used to identify the sequence
{n_rule_1}, {n_rule_2}Non-indexed rules — included in output only, not stored in database
{raw}Raw sequential number
{p_raw,N}Left-padded sequential number (e.g., {p_raw,6}000001)

Unused placeholders are automatically cleaned from the output. This can be disabled via the clean_unused_placeholders config option.

Method Signatures

// Static backward-compatible API
Runner::generate(
    string $format,
    ?string $rule_1 = null,
    ?string $rule_2 = null,
    ?string $rule_3 = null,
    ?string $rule_4 = null,
    ?string $rule_5 = null,
    ?string $n_rule_1 = null,
    ?string $n_rule_2 = null,
): string

// Instance API
$runner->next(/* same signature as generate */): string
$runner->current(?string $rule_1, ..., ?string $rule_5): ?int
$runner->reset(?string $rule_1, ..., ?string $rule_5, int $to = 0): bool

Examples

// TTFN-WPPJ-(P)-000001-2020
Runner::generate(
    "{rule_1}-{rule_2}-{n_rule_1}-{p_raw,6}-{rule_3}",
    "TTFN", "WPPJ", "2020", null, null, "(P)"
);

// T20022200001
Runner::generate(
    "{rule_1}{rule_2}{rule_3}{rule_4}{p_raw,5}",
    "T", "20", "02", "22"
);

How It Works

  • Each unique combination of rule_1 through rule_5 maintains its own independent counter.
  • The counter automatically increments on each call with the same rule combination.
  • Uses pessimistic locking (lockForUpdate()) within a database transaction to prevent race conditions.
  • Rule values must not exceed 100 characters.
  • Format string cannot be empty.

Configuration

// config/runner.php
return [
    'model' => \MyOpensoft\Runner\RunnerModel::class,
    'clean_unused_placeholders' => true,
];

Testing

composer test

Static analysis:

composer phpstan

License

MIT

myopensoft/runner 适用场景与选型建议

myopensoft/runner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.42k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-23