Download the PHP package adamthehutt/laravel-unique-bigint-ids without Composer

On this page you can find all versions of the php package adamthehutt/laravel-unique-bigint-ids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-unique-bigint-ids

Laravel Unique 64-bit Integer IDs

This allows for the generation of sequential IDs that can be created before inserting into the database and are virtually (but not totally) guaranteed to be globally unique for the app.

Installation

Install using composer:

Then publish the configuration:

To use this package with a model, just use the contract and the trait:

DB Migrations

If you are going to use the trait with existing models, then you'll need to create and run migrations to make sure the relevant primary and foreign keys are all unsigned 64-bit integers without auto-increment, e.g.,

What's wrong with UUIDs?

Nothing! UUIDs are great and I use them all the time. But they solve a different category of problems and come with non-trivial challenges when used as primary keys. The IDs generated by this package are plain old integers (albeit very large ones). They are not globally unique like UUIDs. But they are virtually guaranteed to be unique within the scope of your Laravel application.

What's wrong with AUTO_INCREMENT?

Conventional, auto-incremented primary keys are fine if that's your cup of tea. But there are practical benefits from generating an ID in the application upon model creation, rather than waiting until it has been persisted in the database.

Better handling of complex relations

Complex real-world entities often need multiple related eloquent models to be fully represented. This can be awkward with standard auto-incremented IDs since you can't properly associate or attach related models until after the "main" one has been saved to the database. When IDs are assigned on model creation, you can fully associate all related models as they are built and then safely save them to the database without worrying about "last second" assignment of foreign keys.

Fear not sharded databases

If your application uses database shards you don't need to worry about different databases duplicating each other's primary keys.

One fewer roundtrip

There's a tiny performance boost from avoiding the additional roundtrip to the database that comes from calling LAST_INSERT_ID().

Configuration / Strategies

The package provides multiple methods for generating the IDs:

Javascript Gotchas

Javascript barfs on integers larger than 2^53. When serializing models to JSON it's therefore important to cast large 64-bit integers to strings. This package handles that for you, but that only affects the models that use it. If you have other models that don't use this package's trait but have foreign key relationships with those that do, then you'll need to address this when serializing them to JSON.

Alternatively, you can set the environment variable to true. This will cause the library to use slightly reduced precision when generating timestamp-based IDs: 14 significant digits instead of 16. This should not increase the likelihood of collisions, but could result in a very slight performance hit, since it becomes impossible to generate more than 2 IDs in the same 1/10000th of second.


All versions of laravel-unique-bigint-ids with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
illuminate/support Version ^5.8 | ^6.0 | ^7.0 | ^8.0
illuminate/database Version ^5.8 | ^6.0 | ^7.0 | ^8.0
adamthehutt/eloquent-constructed-event Version ^1.0
predis/predis Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package adamthehutt/laravel-unique-bigint-ids contains the following files

Loading the files please wait ....