Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jakyeru/snowflake

Snowflake is a package for Laravel that allows Twitter's 64 bit snowflake to be used as primary identifier for models.
https://github.com/jakyeru/snowflake

laravel php snowflake snowflake-id snowflake-twitter

Last synced: 10 days ago
JSON representation

Snowflake is a package for Laravel that allows Twitter's 64 bit snowflake to be used as primary identifier for models.

Awesome Lists containing this project

README

        






release

# About snowflake
Snowflake is a package for Laravel that allows Twitter's 64 bit snowflake to be used as primary identifier for models.

# Advantages over other identifiers
* Keys begin with a timestamp
* Keys end with a random number, so guessing the size of the table is impossible
* Keys consist entirely of integers, which are handled more efficiently than strings
* Faster key generation (<1ms)
* Standard UUID v4 - 5.6 milliseconds
* Sortable UUID v4 - 8.3 milliseconds
* ULID - 3.1 milliseconds
* **Snowflake - 0.4 milliseconds**

# Installation
```shell
composer require jakyeru/snowflake
```

# Usage
```php
resolve('snowflake')->id(); // ---> 112871594573041664
```
# Usage with Eloquent Models
```php