Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/jakyeru/snowflake
- Owner: JakyeRU
- License: mit
- Created: 2022-11-07T18:41:41.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-13T06:54:03.000Z (over 1 year ago)
- Last Synced: 2024-11-29T18:48:58.463Z (27 days ago)
- Topics: laravel, php, snowflake, snowflake-id, snowflake-twitter
- Language: PHP
- Homepage:
- Size: 515 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# 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