PHPackages                             nocturnalsm/generator - 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. nocturnalsm/generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nocturnalsm/generator
=====================

Code Number Generator for PHP

1.0(4y ago)117MITPHP

Since Aug 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/nocturnalsm/generator)[ Packagist](https://packagist.org/packages/nocturnalsm/generator)[ RSS](/packages/nocturnalsm-generator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Code Number Generator for Laravel
=================================

[](#code-number-generator-for-laravel)

A Laravel package to generate code numbers, such as product numbers, transaction numbers, etc.

Usage
-----

[](#usage)

Use this procedure to generate number

```
$generator = new CodeNumber;
$number = $generator->generate($format, $params);

```

### Parameters

[](#parameters)

#### $format

[](#format)

A string with a number of curly brackets in it where codes will be generated.

Available formats are:

##### **{d:*formatdate*}**

[](#dformatdate)

You can replace *formatdate* with any PHP Date Format.

##### **{r:*randomnumber*}**

[](#rrandomnumber)

This will generate random number with digits in range of the *randomnumber* string length.

For example: with randomnumber 0000 (you can replace 0 with any character you prefer) a random number ranged from 1000 to 9999 will be generated.

##### **{i:*increment*}**

[](#iincrement)

This will generate increments with length of *increment*. You can only include this format once. If there are more than one, only the last occurence will be generated.

For example: {i:0000} will generate 0001, 0002, and so on.

#### $params

[](#params)

You can also specify a string in curly bracket other than the above formats. The string will be replaced by values from this parameter. This will come in handy if you have formats you want to generate your own.

For example:

```
$params = Array("number" => 100);

$generator = new CodeNumber;
return $generator->generate("APP:{number}", $params);

// this will return APP:100

```

### Example Code

[](#example-code)

```
use NocturnalSm\Generator\CodeNumber;

public function generateNumber()
{
    $format = "EX.{d:dmY}.{store}.{i:0000}";
    $generator = new CodeNumber;
    $number = $generator->generate($format, ["store" => "APX");
}

```

Installation
------------

[](#installation)

Use Composer to install this package. Execute script below inside your laravel app directory

`composer require nocturnalsm\generator`

Increment format require a table to hold the data. Publish the migration file by executing the script below

`php artisan vendor:publish --tag=migrations --provider=NocturnalSm\Generator\GeneratorProvider`

To use the package, include the CodeNumber class inside your script

`use NocturnalSm\Generator\CodeNumber`

License
-------

[](#license)

This package has MIT License

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1721d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fd2e17d390eea744c53bbb799c2319356ea0c747df9783d6d626011f885ef245?d=identicon)[nocturnalsm](/maintainers/nocturnalsm)

---

Top Contributors

[![nocturnalsm](https://avatars.githubusercontent.com/u/18625560?v=4)](https://github.com/nocturnalsm "nocturnalsm (1 commits)")

### Embed Badge

![Health badge](/badges/nocturnalsm-generator/health.svg)

```
[![Health](https://phpackages.com/badges/nocturnalsm-generator/health.svg)](https://phpackages.com/packages/nocturnalsm-generator)
```

###  Alternatives

[michael-rubel/laravel-formatters

This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Container to easily extend or override the formatter classes.

9491.6k4](/packages/michael-rubel-laravel-formatters)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
