Download the PHP package mawuekom/laravel-model-uuid without Composer

On this page you can find all versions of the php package mawuekom/laravel-model-uuid. 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-model-uuid

Laravel Model UUIDs

Latest Version on Packagist Total Downloads GitHub Actions

A simple solution to easily work with UUIDs in your Laravel models.

This package provides a way to generate and work with RFC 4122 version 1, 2, 3, 4, and 5 universally unique identifiers (UUID). It also supports optional and non-standard features, such as [version 6 UUIDs], GUIDs, and other approaches for encoding/decoding UUIDs.

It based on ramsey/uuid package.
Take a look on this for more details.

What Is a UUID?

A universally unique identifier, or UUID, is a 128-bit unsigned integer, usually represented as a hexadecimal string split into five groups with dashes. The most widely-known and used types of UUIDs are defined by RFC 4122.

A UUID, when encoded in hexadecimal string format, looks like:

The probability of duplicating a UUID is close to zero, so they are a great choice for generating unique identifiers in distributed systems.

UUIDs can also be stored in binary format, as a string of 16 bytes.

It is suggested to use UUIDs in your responses instead of IDs, which are generally enumerable.

This will help mitigate some forms of enumeration attacks.

Note: This package explicitly does not disable auto-incrementing on your Eloquent models. In terms of database indexing, it is generally more efficient to use auto-incrementing integers for your internal querying. Indexing your uuid column will make lookups against that column fast, without impacting queries between related models.

Installation

You can install the package via composer:

Usage

To use this package, you simply need to import and use the trait within your Eloquent models.

It is assumed that you already have a field named uuid in your database, which is used to store the generated value. If you wish to use a custom column name, for example if you want your primary id column to be a UUID, you can define a uuidColumn method in your model.

You can have multiple UUID columns in each table by specifying an array in the uuidColumns method. When querying using the whereUuid scope, the default column - specified by uuidColumn will be used.

By default, this package will use UUID version 4 values, however, you are welcome to use uuid1, uuid3, uuid4, or uuid5 by specifying the protected property $uuidVersion in your model. Should you wish to take advantage of ordered UUID (version 4) values that were introduced in Laravel 5.6, you should specify ordered as the $uuidVersion in your model.

This trait also provides a query scope which will allow you to easily find your records based on their UUID, and respects any custom field name you choose.

It also have methods

There is also ValidatesUuid trait which as his name says validate incoming UUID before make model queries.

You can use it in your Controller too :

There is also a useful helper function is_the_given_id_a_uuid that return true if the given id is a uuid or false if not.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-model-uuid with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^7.3|^7.4|^8.0|^8.1|^8.2|^8.3
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
ramsey/uuid Version ^4.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 mawuekom/laravel-model-uuid contains the following files

Loading the files please wait ....