64 bit ID Generator

Overview

Build Status Latest Stable Version License

Particle

Language: PHP

64bits int Time Based ID Generator

Uncoordinated

For high availability within and across data centers, machines generating ids should not have to coordinate with each other.

Solution

  • PHP (tested on v7.1.8)
  • Particle Id (64 bits) is composed of:
    • time - 42 bits (millisecond precision w/ a custom epoch)
    • configured machine id - 10 bits - up to 1024 machines
    • sequence number - 12 bits - up to 4096 random numbers

System Clock Dependency

You should use NTP to keep your system clock accurate.

How to use it

Generate Particle ID

Change const EPOCH in particle class to today epoch time w/ miliseconds (13 digits)

	$machineID = 0; // Machine ID (aka Server ID no.)
	Particle::generateParticle($machineID);

Time from Particle ID (w/ milisecond precision)

	$particleID = '4611692470816737853';
	Particle::timeFromParticle($particleID);
You might also like...
Runtime Code Generator like Lombok for PocketMine-MP
Runtime Code Generator like Lombok for PocketMine-MP

PlumbokPM Runtime Code Generator like Lombok for PocketMine-MP. Code generation starts when additional autoloader detects class uses PlumbokPM annotat

Windowy is a transaction-focused temporary inventory generator made for PocketMine-MP

About Windowy is a transaction-focused temporary inventory generator made for PocketMine-MP. How to use Windowy comes with 3 registered inventories us

DTO Generator - PHP library for generating DTO classes

DTO Generator PHP library for generating DTO classes. Installation Use the package manager composer to install micro/dto. composer require micro/dto U

A QR Code generator for PHP7.4+

chillerlan/php-qrcode A PHP 7.4+ QR Code library based on the implementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff. Docu

Stupid async implementation using await-generator

libAsync Stupid async implementation using await-generator Usage libAsync::doAsync(Closure $executor); // -- Returns a promise Example Fetch data fro

Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links.
Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links.

Infopanel is a simple tool getting some information from source. It works basically like a slider that shows only title, image, a little bit description and QR-Code for links. It has its own GUI for the editing. The GUI provides a very simple role concept. This tool can be used for digital signage, Information panels, News or Events or similar.

A dumb sharing site for photos and videos, made by me, using a bit of borrowed code.
A dumb sharing site for photos and videos, made by me, using a bit of borrowed code.

ShitShare A dumb sharing site for photos and videos, made by me, using a bit of borrowed code. Information This was made on Windows, so when video upl

AES 128 bit Encryption and Decryption algorithm excuted purely on PHP with no external libraries.
AES 128 bit Encryption and Decryption algorithm excuted purely on PHP with no external libraries.

AES128 Executed with PHP Advanced Encryption Standard (AES) is a specification for the encryption of electronic data established by the U.S National I

InfyOm Laravel Generator - API, Scaffold, Tests, CRUD Laravel Generator
InfyOm Laravel Generator - API, Scaffold, Tests, CRUD Laravel Generator

InfyOm Laravel Generator Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes. Read

Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless development of your applications.
Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless development of your applications.

Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless develop

Laravel Design Pattern Generator (api generator)
Laravel Design Pattern Generator (api generator)

Laravel Design Pattern Generator (api generator) you can create your restful api easily by using this library and you can filter, sort and include elo

One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP
One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP

otp-thing One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP Introduction This started

This bundle provides new generator command line tools for doctrine generator.

GenBundle This bundle provides new generator command line tools for doctrine generator, extending SensioGeneratorBundle. php bin/console gen:generate:

A PHP project/micro-package generator for PDS compliant projects or micro-packages.

Construct A PHP project/micro-package generator for PDS compliant projects or micro-packages. Installation Construct should be installed globally thro

CRUDlex is an easy to use CRUD generator for Symfony 4 and Silex 2 which is great for auto generated admin pages
CRUDlex is an easy to use CRUD generator for Symfony 4 and Silex 2 which is great for auto generated admin pages

CRUDlex CRUDlex is an easy to use, well documented and tested CRUD generator for Symfony 4 and Silex 2. It is very useful to generate admin pages for

Simple static Composer repository generator - For a full private Composer repo use Private Packagist

Satis Simple static Composer repository generator. Run from source Satis requires a recent PHP version, it does not run with unsupported PHP versions.

Daux.io is an documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It helps you create great looking documentation in a developer friendly way.

Daux.io - Deprecation Notice This repository is deprecated! Daux.io has been moved to an organization, to guarantee future development and support. So

Documentation Generator for PHP

phpDocumentor What is phpDocumentor? phpDocumentor is an application that is capable of analyzing your PHP source code and DocBlock comments to genera

An API documentation generator

Sami: an API documentation generator WARNING: Sami is not supported nor maintained anymore. Feel free to fork. Curious about what Sami generates? Have

Comments
  • Duplicated ID's for different $machine_id's

    Duplicated ID's for different $machine_id's

    After running the following test http://3v4l.org/eHKCc and getting the following output for 5.5.3 (and other versions)

    Same machine same time
    1395792668864
    1395792668864
    1395792668864
    1395792668864
    1395792668864
    1395792668864
    Different machine same time
    1395792668864
    1395792668864
    1395792668864
    1395792668864
    1395792668864
    1395792668864
    Same machine different time
    1395792668865
    1395792668867
    1395792668868
    1395792668869
    1395792668870
    1395792668871
    

    It looks like Particle will:

    • Generate the same ID if the code is called multiple times in less than 1ms.
    • Generate the same ID even when using a different $machine_id

    Using usleep(1000) between calls could prevent the same id's when running on the same process, but does not prevent two processes on the same machine from producing the same ID.

    It looks like some implementations like https://github.com/T-PWK/flake-idgen are using a worker id, which could potentially be the pid of the process. This could solve the same server different process issue.

    But the $machine_id issue seems like a bug to me unless I'm not using Particle correctly.

    Are these known issues? Can they be addressed/prevented? Could the docs include details about these limitations?

    Thanks

    opened by bermi 4
  • Why are only half the possible machine IDs and sequence numbers used?

    Why are only half the possible machine IDs and sequence numbers used?

    I might be misunderstanding something really basic here. But according to README.md...

    configured machine id - 10 bits - up to 512 machines sequence number - 12 bits - up to 2048 random numbers

    Why are only half of the values available for each of these? i.e....

    • 10 bits allows 1024 values, so why only up to 512 machines?
    • 12 bits allows 4096 values, so why only up to 2048 random numbers for sequence?
    enhancement 
    opened by hi2u 3
  • I got the wrong result.

    I got the wrong result.

    I use this library,and got all the $particleID num string like "2.5100994530733E+14".Is this the right result? The $particleID is it like "4611692470816737853"?

    invalid 
    opened by xiangjihan 3
  • Id Length

    Id Length

    Hi,

    The Twitter/Snowflake IDs are all exactly 20 digits in length but with Particle they vary.

    Is there a reason for this and/or any way to have them work in the same way?

    Thanks

    invalid 
    opened by oasiz 2
Releases(v2.2.2)
Owner
Silviu | ซีลวิอุ
Treat everyone with kindness and respect 🙏🏻🤍
Silviu | ซีลวิอุ
Contracts for Rule Doc Generator. Useful for production code with minimum dependencies.

Rule Doc Generator Contracts Contracts for Rule Doc Generator. Useful for production code with minimum dependencies. Install composer require symplify

null 19 Dec 22, 2022
Algerian code generator for invoices, quotes or any commercial documents

Algerian invoice code generator The library is useful to generate code for invoices, quotes or any commercial transaction document. Goal Is to provide

Hippone Consulting 7 Jul 19, 2021
Magento 2 Code Generator

Magento 2 Code Generator Created by Orba Inspired by https://github.com/staempfli/magento2-code-generator Purpose In day-to-day Magento 2 development

null 74 Nov 14, 2022
PHP Sitemap Generator

This class can be used to generate sitemaps and notify updates to search engines.

Paweł Antczak 146 Nov 15, 2022
A simple e-Certificate generator.

SeaJell A simple e-Certificate Generator. Guides You can read all the guides in using the system from the documentation. License Copyright (c) Muhamma

The SeaJell Project 22 Oct 4, 2022
Wordpress Plugin Boilerplate but Powered with examples and a generator!

WordPress Plugin Boilerplate Powered WordPress Plugin Boilerplate Powered is a complete foundation for building your WordPress plugins following PSR-4

WordPress Plugin Boilerplate Powered 604 Dec 24, 2022
Rah sitemap - XML sitemap generator for Textpattern CMS

rah_sitemap Packagist | Issues | Donate Sitemap plugin for Textpattern CMS. Generates Sitemaps.org XML sitemaps for your site, which help Google and o

Jukka Svahn 7 May 13, 2022
Invoice PDF Generator For Magento 2

Magento Invoice PDF Generator Magento 2 Invoice PDF Generator - helps you to customize the pdf templates for Magento 2. If you have an enabled templat

EAdesign 66 Dec 13, 2022
Code generator for Magento 2

Magento 2 Code Generator Tool Installation Option1: Downloading .phar wget https://github.com/staempfli/magento2-code-generator/releases/download/<ver

Stämpfli AG 254 Dec 5, 2022
Laravelium Sitemap generator for Laravel

Laravelium Sitemap package Laravelium Sitemap generator for Laravel. Notes Dev Branches are for development and are UNSTABLE (use on your own risk)! I

Laravelium 1.3k Dec 30, 2022