nubitio/sequence-bundle
Composer 安装命令:
composer require nubitio/sequence-bundle
包简介
Opt-in atomic field numbering for Nubit Symfony apps via the Sequence attribute and a shared counter table.
README 文档
README
Opt-in atomic numbering for document fields.
Install
composer require nubitio/sequence-bundle
Create the counter table (once per app):
CREATE TABLE nubit_sequence_counter ( id SERIAL PRIMARY KEY, scope_key VARCHAR(190) NOT NULL, name VARCHAR(64) NOT NULL, next_value INT NOT NULL DEFAULT 1, CONSTRAINT UNIQ_SEQUENCE_SCOPE_NAME UNIQUE (scope_key, name) );
Or run a Doctrine migration that maps Nubit\SequenceBundle\Entity\SequenceCounter.
Usage
use Nubit\SequenceBundle\Attribute\Sequence; #[Sequence(field: 'number', name: 'order', prefix: 'ORD-', padding: 4, scope: ['restaurant'])] class Order { // number is allocated on POST when left empty }
Counters are isolated per scope (restaurant:1|…) and sequence name (order).
Frontend integration
The Hydra API doc publishes x-sequence on the resource class so @nubitio/react-admin hides the allocated field on create/edit forms and marks it read-only in the grid:
{
"@id": "#Order",
"x-sequence": {
"field": "number",
"name": "order",
"prefix": "ORD-",
"padding": 4,
"scope": ["restaurant"]
}
}
No manual visibleOnForm: false on the sequence property is required when the bundle is enabled.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-19