Demo https://phpsngenerator.herokuapp.com/
Customable Serial Number Generator for PHP.
Where can this be used?
- Serial number on the application
- Security Token
- Reset Password link token
- API Key
composer require irfa/php-sn-generator
You can get Composer here
'providers' => [
....
Irfa\SerialNumber\SerialNumberGeneratorSeviceProvider::class,
];
'aliases' => [
....
'SN' => Irfa\SerialNumber\Facades\SerialNumber::class,
],
php artisan vendor:publish --tag=php-serial-number
config/irfa/serial_number.php
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",
];
<?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
}
}
<?php
require "vendor/autoload.php";
use Irfa\SerialNumber\Func\SerialNumber;
$sn = new SerialNumber();
echo $sn->generate(); //result : TP8K-XU63-9YN3-SMSF
//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();
- 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.
- 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
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.