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

On this page you can find all versions of the php package dyrynda/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

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads License Dependency Status Buy us a tree

Introduction

I find myself using UUID across multiple projects of late, and packaged up this functionality rather than copying and pasting it from project to project.

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.

For more information, check out this post on storing and working with UUID in an optimised manner.

Take a look at laravel-efficient-uuid if you want to make it easy to generate migrations that efficiently store UUID in your database.

If you require compatibility with ramsey/uuid >= 4.1, please use version >= 6.2.0 of this package.

As of version 7.1.0 this package supports only UUID versions 1 (uuid1), 4 (uuid4), 6 (uuid6 - ordered) and ordered (Laravel's ordered UUID v4) and 7 (uuid7).

This package supports Laravel 10 and PHP 8.1 as minimum.

Code Samples

In order 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.

The package will use uuid as the column name to store the generated UUID value by default. If you prefer a different name, you may change the model-uuid.column_name config variable.

You may also override the uuidColumn method on a per-model basis.

By default, this package will use UUID version 4 values, however, you are welcome to use uuid1, uuid4, uuid6, or uuid7 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.

Whilst not recommended, if you do choose to use a UUID as your primary model key (id), be sure to configure your model for this setup correctly. Not updating these properties will lead to Laravel attempting to convert your id column to an integer, which will be cast to 0. When used in combination with laravel-efficient-uuid, this casting will result in a Ramsey\Uuid\Exception\InvalidUuidStringException being thrown.

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.

If you use the suggested laravel-efficient-uuid package, you will need to add a cast to your model in order to correctly set and retrieve your UUID values. This will ensure your UUIDs are written to your (MySQL) database as binary and presented as strings.

Route model binding

From 6.5.0, should you wish to leverage implicit route model binding on your uuid field, you may use the BindsOnUuid trait, which will use the configured uuidColumn by default.

Should you require additional control over the binding, or are using < 6.5.0 of this package, you may override the getRouteKeyName method directly.

If you are using the laravel-efficient-uuid package, implicit route model binding won't work out of the box.

Laravel will execute the query using the string representation of the uuid field when querying against the binary data stored in the database. In this instance, you will need to explicitly bind the parameter using the included scope in your RouteServiceProvider:

Installation

This package is installed via Composer. To install, run the following command.

If you wish to override default configuration, you may publish the configuration file to your application.

Support

If you are having general issues with this package, feel free to contact me on Twitter.

If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request.

If you're using this package, I'd love to hear your thoughts. Thanks!

Treeware

You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees here

Read more about Treeware at treeware.earth


All versions of laravel-model-uuid with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/container Version ^11.15
illuminate/contracts Version ^11.15
illuminate/database Version ^11.15
illuminate/events Version ^11.15
illuminate/support Version ^11.15
ramsey/uuid Version ^4.7
spatie/laravel-package-tools Version ^1.16
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 dyrynda/laravel-model-uuid contains the following files

Loading the files please wait ....