Download the PHP package xthiago/id-value-object without Composer

On this page you can find all versions of the php package xthiago/id-value-object. 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 id-value-object

Id Value Object

PHP library to make working with object identity (ID) easier and fun!

In short: You shouldn't rely on database mechanisms to generate IDs. Also, you shouldn't manipulate scalar values (usual int) over all the application. Wherever you need to generate an ID, use this ID value object.

Features

UUID v4

The library automatically generates UUID v4 as ID. You will not rely on persistence mechanism and flush operations to generate identity.

Integration with Doctrine

The library comes with a Doctrine DBAL Type which allows you to map the Id value object as an Doctrine Entity attribute.

Requirements

This library requires PHP >= 7.2.

Installation

Use composer to install the library.

Doctrine

To make use of Doctrine integration for persistence you have to configure the Doctrine DBAL Type given by this package.

Standalone Doctrine

You must register the DBAL Type in your application boostrap like following:

Symfony Framework

If you are using Symfony, you just need to edit the following the Doctrine configuration to add the following:

Usage

Basic examples:

`

Mapping Id in your entity class (e.g. Product):

Creating custom ID classes

Instead of rely on a generic Id class for all entities, you can create specific value objects for each entity.

For example, give you have a Product entity, you can create a ProductId value object in the following way:

Then you will need to map this new type. You can just extend DoctrineDbalType in the following way:

Then you configure this new type (e.g. Type::addType(ProductIdDbalType::NAME, ProductIdDbalType::class);) and start using it in your model (this time I will show the mapping using PHP Attributes):

Symfony Serializer

This library includes a class IdInterfaceNormalizer able to normalize and denormalize instances of Id value object.

To use that normalizer, you need to pass it as an argument of Serializer class constructor:

FreezesUuidTrait utility to help with tests

When creating tests, we may want to know the value of the generated IDs beforehand. This lets us write more simpler assertions. This library provides a trait FreezesUuidTrait that could be used to freeze the uuid v4 generation or to set a known sequence.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT


All versions of id-value-object with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.2
ramsey/uuid Version ^4.1
ext-json Version *
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 xthiago/id-value-object contains the following files

Loading the files please wait ....