Skip to content

irfaardy/php-sn-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀PHP Serial Number Generator

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

Demo https://phpsngenerator.herokuapp.com/ or demo source code https://github.com/irfaardy/php-sn-generator-demo

Customable Serial Number Generator for PHP.

Where can this be used?

  1. Serial number on the application
  2. Security Token
  3. Vouchers Serial
  4. Activation Apps Serial
  5. Reset Password link token
  6. API Key
  7. etc.

🛠️ 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.