PHPackages                             lsb/numbering-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lsb/numbering-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

lsb/numbering-bundle
====================

Number generator for Symfony applications

v1.0.2(6y ago)13MITPHPPHP &gt;=7.2CI failing

Since May 8Pushed 6y agoCompare

[ Source](https://github.com/LSBDataWeFeelIT/LSBNumberingBundle)[ Packagist](https://packagist.org/packages/lsb/numbering-bundle)[ Docs](https://lsb.pl)[ RSS](/packages/lsb-numbering-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

LSBNumberingBundle
------------------

[](#lsbnumberingbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/1ddbd8554851bb5c896b59062dde8192c3115c53ded1c5362a4a631d0736422e/68747470733a2f2f706f7365722e707567782e6f72672f6c73622f6e756d626572696e672d62756e646c652f762f737461626c65)](https://packagist.org/packages/lsb/numbering-bundle) [![Build Status](https://camo.githubusercontent.com/67843f44a3a3375f81d330f66fc1c0233ae52d451e0034ff03c35f95cdfea14b/68747470733a2f2f7472617669732d63692e636f6d2f4c53424461746157654665656c49542f4c53424e756d626572696e6742756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/LSBDataWeFeelIT/LSBNumberingBundle) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/1ddd0670d5a930f3314090d08ecdbd66c69cf87ef3ccb3da5407bb806478944c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c53424461746157654665656c49542f4c53424e756d626572696e6742756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LSBDataWeFeelIT/LSBNumberingBundle/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/a5e54ce6674db3149edea625133f2cbaa2b6979206c096ed9c0a0df444500233/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c53424461746157654665656c49542f4c53424e756d626572696e6742756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LSBDataWeFeelIT/LSBNumberingBundle/?branch=master)

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

[](#installation)

```
composer require lsb/numbering-bundle

```

### Configuration

[](#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:

[](#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:

[](#tags)

Tag nameRequiredModifiersDescription{number}yeslengthcurrent value of the counter{year}nolength \[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

[](#usage)

A subject object is any object you want to generate numbers for. It needs to implement NumberableInterface.

```
