lsb/numbering-bundle
Composer 安装命令:
composer require lsb/numbering-bundle
包简介
Number generator for Symfony applications
关键字:
README 文档
README
This bundle provides functionality of generating subsequent numbers for any given object e.g. Order, Invoice etc. in Symfony 5 applications.
It creates a simple config in system database, which stores current counter and context data.
Installation
composer require lsb/numbering-bundle
Configuration
Configure the bundle by defining patterns and counter config data in lsb_numbering.yaml file.
# examples of configuration
lsb_numbering:
patterns:
- { name: pattern1, pattern: 'IN/{year}/{number|6}'}
- { name: pattern2, pattern: "ON/{day}/{number|4}"}
- { name: pattern3, pattern: "{number|5}-{context_object}-{month}"}
counter_configs:
- {name: counterConfig1, patternName: pattern1, step: 1, start: 10 }
- {name: counterConfig2, patternName: pattern2, step: 2, start: 20, time_context: year }
- {name: counterConfig3, patternName: pattern3, step: 3, start: 30, time_context: month, context_object_fqcn: "App/Entity/Branch" }
Rules of configuration:
- Number patterns can be defined by any string with predefined tags (see Tags section)
- Tags must be enclosed in curly brackets
- Only {number} tag is required
- Counters can work in time context
- Some tags can be followed by a length modifier e.g {year|2}, {number|6} which limits the resolved value to the given length.
Tags:
| Tag name | Required | Modifiers | Description |
|---|---|---|---|
| {number} | yes | length | current value of the counter |
| {year} | no | length [2,4] | current year |
| {semester} | no | - | current semester of the year |
| {quarter} | no | - | current quarter of the year |
| {month} | no | - | current month of the year |
| {week} | no | - | current week of the year |
| {day} | no | - | current day of the year |
| {context_object} | no | - | context object value |
Usage
A subject object is any object you want to generate numbers for. It needs to implement NumberableInterface.
<?php
namespace App\Entity;
use LSB\NumberingBundle\Interfaces\NumberableInterface;
class Order implements NumberableInterface
{
// class body
}
Example of usage NumberingGenerator service
<?php
namespace App\Service;
use App\Entity\Order;
use LSB\NumberingBundle\Model\GeneratorOptions;
use LSB\NumberingBundle\Service\NumberingGenerator;
use LSB\NumberingBundle\Interfaces\NumberableInterface;
class ExampleService
{
/** @var NumberingGenerator */
protected $ng;
public function __construct(NumberingGenerator $generator)
{
$this->ng = $generator;
}
public function exampleNumbers(): void
{
// subject example object
$order = new Order();
// options object
$options = new GeneratorOptions('counterConfig1');
// generate number
$simpleNumber = $this->ng->generateNumber($order, $options);
// returns resolved number e.g. IN/2020/000001
$simpleNumber->getNumber();
}
}
License
LSBNumberingBundle is available under an MIT License.
lsb/numbering-bundle 适用场景与选型建议
lsb/numbering-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「generator」 「number」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lsb/numbering-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lsb/numbering-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lsb/numbering-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
The bundle for easy using json-rpc api on your project
A package for working with arbitrary precision numbers in Laravel.
Gambling Algorithms for Certification.
Bundle Symfony DaplosBundle
Validates Turkish National Identification Number
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-09