2017 © Pedro Peláez
 

symfony-bundle sequence-bundle

Symfony bundle that provides ability to create multiple sequences for invoice / user codes. Saving to database or files

image

kebza/sequence-bundle

Symfony bundle that provides ability to create multiple sequences for invoice / user codes. Saving to database or files

  • Monday, August 7, 2017
  • by mkebza
  • Repository
  • 1 Watchers
  • 0 Stars
  • 30 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

Sequence bundle

Generating sequences (for invoices / orders / ...). With ability to have custom format for numbering., (*1)

Installation:

composer require kebza/sequence-bundle

Enable bundle in AppKernel, (*2)

``` php, (*3)

app/AppKernel.php

public function registerBundles() { $bundles = array( // ... new Kebza\SequenceBundle\KebzaSequenceBundle(), // ... ); }, (*4)


If you are using doctrine storage, you need to add mapping to your entity manager. ```yaml doctrine: orm: mappings: KebzaSequenceBundle: ~

and then update your database schema, (*5)

php bin/console doctine:schema:update

Configuration

Before you start you need to configure your sequences., (*6)

kebza_sequence:
    storage: doctrine # file | memory
    sequences:
        first:
            pattern: '{YYYY}{ID|6|WEEK}'
            step: 1
            initial: 1
        second:
            pattern: '{YY}{WW}{ID|6|WEEK}'
            step: 1
            initial: 1

Usage

You can use sequences by requestiong kebza.sequence.manager service with its methods., (*7)

// From controller
$manager = $this->get('kebza.sequence.manager');
$manager->current('first'); // If sequence not initialized, returns null otherwise current formatted value
$manager->next('first'); // Returns next value
$manager->increment('first'); // Increments by configuration of step.

Storages:

  • doctrine - saves sequences in database
  • file - saves information into files in directory
  • memory - Once script ends, info about sequences is lost

Pattern

In pattern there is possible to use replaces to format final output:, (*8)

  • {ID|X|Y} - Replaces ID with current number. If X is specified, will add padding using zeroes to final length. Y can be YEAR, MONTH, WEEK and means that sequence will reset on every new year, month, week
  • {YYYY} - Year - 2017
  • {YY} - Year - 17
  • {MM} - month 12
  • {WW} - Week number

The Versions

07/08 2017

dev-master

9999999-dev

Symfony bundle that provides ability to create multiple sequences for invoice / user codes. Saving to database or files

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marek Kebza

bundle doctrine symfony files sequence

07/08 2017

1.0.0

1.0.0.0

Symfony bundle that provides ability to create multiple sequences for invoice / user codes. Saving to database or files

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marek Kebza

bundle doctrine symfony files sequence