Multi-Variant

The Contracts Library is multi-variant. What does that mean?

What Is Multi-Variant?

In a normal library, when you install it via composer, you get one version of the library. You'll choose between version 1.x, version 2.x, version 3.x and so on.

In a multi-variant library, the library includes all of the different versions. You get version 1.x, version 2.x and version 3.x (and so on) installed at the same time. Each version of the library has its own namespace. Your code can use multiple versions at the same time.

The Contracts Library uses these namespaces:

These are the library's API versions.

Why Do We Need Multi-Variant Libraries?

Version 2.x of a library's API is normally incompatible with version 1.x of the same library. This is good practice. Unfortunately, that leads to some problems with PHP's lack of code module support.

As a result, the Composer package manager won't let you install both version 1.x and version 2.x of the same library at the same time.

This becomes a blocker when your application has dependencies that use different versions of the same library. All of a sudden, you have conflicts in Composer that you cannot resolve.

Multi-variant libraries avoid this problem entirely.

How Do We Version Multi-Variant Libraries?

Multi-variant libraries use v1.YYYYMMDDRR style for Git tags:

For example: v1.2016041401, or v1.2016041502.

Why are there no '.' between the different parts?