irfa / php-sn-generator
"Serial number generator for web aplication"
Fund package maintenance!
Patreon
Ko Fi
buymeacoff.ee/irfaardy
Installs: 3 723
Dependents: 3
Suggesters: 0
Security: 0
Stars: 18
Watchers: 1
Forks: 16
Open Issues: 0
Type:package
Requires
- php: ~5.6|~7.0|~8.0
- ext-json: *
- hidehalo/nanoid-php: 1.1.8
This package is auto-updated.
Last update: 2024-11-30 02:08:24 UTC
README
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?
- Serial number on the application
- Security Token
- Vouchers Serial
- Activation Apps Serial
- Reset Password link token
- API Key
- 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?
- Fork it (https://github.com/irfaardy/php-sn-generator/fork)
- Commit your changes (
git commit -m 'New Feature'
) - Push to the branch (`git push origin your-branch)
- 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?
- Lakukan fork di (https://github.com/irfaardy/php-sn-generator/fork)
- Commit perubahan yang anda lakukan (
git commit -m 'Fitur Baru'
) - Push ke branch master (`git push origin branch-kamu)
- 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.