Skip to content

Customable Serial Number Generator for PHP Native, Laravel and other PHP Framework

License

Notifications You must be signed in to change notification settings

indihealth-2021/php-sn-generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀PHP Serial Number Generator

Maintainability Scrutinizer Code Quality PHP Composer Latest Stable Version GitHub license
Support me ko-fi

Demo https://phpsngenerator.herokuapp.com/

Customable Serial Number Generator for PHP.

Where can this be used?

  1. Serial number on the application
  2. Security Token
  3. Reset Password link token
  4. API Key

🛠️ Installation with Composer

composer require irfa/php-sn-generator

You can get Composer here


🛠️ Laravel Setup

Add to config/app.php

'providers' => [
            ....
            Irfa\SerialNumber\SerialNumberGeneratorSeviceProvider::class,
     ];

Add to config/app.php

'aliases' => [
         ....
  		'SN' => Irfa\SerialNumber\Facades\SerialNumber::class,

    ],

Publish Vendor

php artisan vendor:publish --tag=php-serial-number

Config File

Config Laravel

config/irfa/serial_number.php

Config non-Laravel or PHP Native

vendor/irfa/php-sn-generator/config/config.php
<?php 
	return [ 
	/*
    |--------------------------------------------------------------------------
    | Serial Config
    |--------------------------------------------------------------------------
    |
    | length    : length for one segment
    | segment   : segment amount for Serial number 
    | seperator : striped segment for serial (set null if you do not wish to use seperator)
    |
    */
		'length'	=> 4,

		'segment'	=> 4,
	
	    	'seperator'     => "-",
	
	    	'charset'       => "0123456789ABCDEFGHIJKLMNPQRSTUWXYZ",

];

Example Generate Serial Number (Laravel)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use SN;

class SomethingController extends Controller
{
   
    public function generate_serial(Request $request)
    {
        return SN::generate(); //result : TP8K-XU63-9YN3-SMSF
    }
}

Example Generate Serial Number PHP Native

<?php
require "vendor/autoload.php";
use Irfa\SerialNumber\Func\SerialNumber;

$sn = new SerialNumber();

echo $sn->generate(); //result : TP8K-XU63-9YN3-SMSF
   

Other Function

Programmatically Config

//Laravel
SN::setConfig([	
		'length' => 5,
		'segment' => 4,
		'seperator' => '-',
		'charset' => "123456789ABCDEFGH"])
	->generate();
	
//PHP Native
$sn = new SerialNumber();

echo $sn->setConfig([	
                        'length' => 5,
                        'segment' => 4,
                        'seperator' => '-',
                        'charset' => "123456789ABCDEFGH"
                    ])
		->generate();

How to Contributing?

  1. Fork it (https://github.com/irfaardy/php-sn-generator/fork)
  2. Commit your changes (git commit -m 'New Feature')
  3. Push to the branch (`git push origin your-branch)
  4. Create a new Pull Request your-branch -> master

if you found bug or error, please post here https://github.com/irfaardy/php-sn-generator/issues so that they can be maintained together.


Bagaimana cara berkontribusi?

  1. Lakukan fork di (https://github.com/irfaardy/php-sn-generator/fork)
  2. Commit perubahan yang anda lakukan (git commit -m 'Fitur Baru')
  3. Push ke branch master (`git push origin branch-kamu)
  4. Buat Pull Request baru branch-kamu -> master

Issue

If you found issues or bug please create new issues here https://github.com/irfaardy/php-sn-generator/issues/new

Jika anda menemukan bug atau error silahkan posting disini https://github.com/irfaardy/php-sn-generator/issues agar dapat diperbaiki bersama-sama.


About

Customable Serial Number Generator for PHP Native, Laravel and other PHP Framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%