PHPackages                             jakyeru/snowflake - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. jakyeru/snowflake

ActiveLibrary

jakyeru/snowflake
=================

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

v1.0.3(2y ago)013MITPHPPHP &gt;=8.0CI failing

Since Nov 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/JakyeRU/snowflake)[ Packagist](https://packagist.org/packages/jakyeru/snowflake)[ Docs](https://github.com/jakyeru/snowflake)[ RSS](/packages/jakyeru-snowflake/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

 [ ![](https://raw.githubusercontent.com/JakyeRU/snowflake/main/.github/logo/Snowflake-logos_transparent.png) ](https://github.com/JakyeRU/snowflake)

 [![release](https://camo.githubusercontent.com/cd6e41d1dc5aa17391d41d1763dd19ad1fdac8d8c8ab7fe30ac847c1d19eb213/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a616b796572752f736e6f77666c616b653f6c6f676f3d67697468756226636f6c6f723d626c7565267374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/cd6e41d1dc5aa17391d41d1763dd19ad1fdac8d8c8ab7fe30ac847c1d19eb213/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6a616b796572752f736e6f77666c616b653f6c6f676f3d67697468756226636f6c6f723d626c7565267374796c653d666f722d7468652d6261646765)

About snowflake
===============

[](#about-snowflake)

Snowflake is a package for Laravel that allows [Twitter's 64 bit snowflake](https://en.wikipedia.org/wiki/Snowflake_ID) to be used as primary identifier for models.

Advantages over other identifiers
=================================

[](#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 (&lt;1ms)
    - Standard UUID v4 - 5.6 milliseconds
    - Sortable UUID v4 - 8.3 milliseconds
    - ULID - 3.1 milliseconds
    - **Snowflake - 0.4 milliseconds**

Installation
============

[](#installation)

```
composer require jakyeru/snowflake
```

Usage
=====

[](#usage)

```
resolve('snowflake')->id(); // ---> 112871594573041664
```

Usage with Eloquent Models
==========================

[](#usage-with-eloquent-models)

```
