Download the PHP package mistralys/version-parser without Composer

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

Version string parser for PHP

PHP utility used to parse application version strings, and retrieve information on the version, as well as convert it to a numeric build number (float or integer). Supports release tags like alpha, beta and reelease candidate, as well as custom branch names.

Supported version strings

The parser expects versions to be in the following format:

MajorVersion.MinorVersion.PatchVersion-BranchOrTag

This allows the use of a wide range of version strings. Some examples:

Most special characters are filtered out, which means that it is very lenient in what is passed to it. After the version number, anything that is not a tag qualifier (beta, alpha, etc.) is considered the branch name.

Installation

Simply require the package with composer.

Via command line:

Via composer.json:

Usage

Getting individual version numbers

Getting a version without tag

The version is normalized to show all three levels, even if they were not specified.

Getting a short version

The method getShortVersion() retrieves a version string with the minimum possible levels.

Getting the full version, normalized

NOTE: The branch name is also normalized. Words are capitalized, and spaces are removed. Other special characters are preserved.

Checking the tag type

To check the release type, the shorthand methods isBeta(), isAlpha(), etc. can be used. See "Supported release tags" for details.

Alternatively, it is possible to check the tag type manually.

The tag info object that can be accessed with the getTagInfo() method goes more in depth.

For example, the method getTagName() will return the tag type exactly as used in the version string, whereas getTagType() will only return the long type variant (e.g. beta instead of b):

Getting the tag number

When no number is added to the tag, it is assumed that it is the tag #1.

With a number added:

Getting the branch name

This also works in combination with a release tag:

Branch names may contain special characters. Quotes are filtered out:

Setting the separator character

By default, the branch name and tag are separated with hyphens (-) when normalizing the version string. This can be adjusted to any character:

Will output:

Converting tag types to uppercase

By default, tag types are converted to lowercase when normalizing the version string. They can be switched to uppercase instead:

Will output:

Supported release tags

The parser will handle the following tags automatically, and assign them a build number value:

This means that comparing the same version numbers with different release tags will work. For example, 1.4-beta is considered a higher version than 1.4-alpha, because beta has a lower weight than alpha.

Numbering tags

Also supported is numbering tagged versions:

Adding custom tags

If you use other tag types in your application's version strings, they can be added so the parser recognizes them:

If you mix custom tag types and the standard ones, be careful with the sorting weight you set for them, so they will be weighted correctly. If needed, you can change the weight of the default types to make more room.

This for example resets the weights for some existing tag types, and inserts new ones:

NOTE: The weights are used in the generated build numbers. Changing the default tag type weights will change their build numbers as well.

Build numbers

The version strings are intelligently converted to numbers, to allow comparisons and sorting. This includes the release tags like alpha or beta, which are converted as well. The result is a build number which can be either a floating point number, or an integer.

NOTE: These numbers are not meant to be human-readable. Their sole purpose is to recognize version numbers programmatically.

There are two methods related to this:

Sorting versions

The best way to sort versions is to use the build numbers, which allow numeric comparisons. Here's an example that sorts them in ascending order:

This will sort the list the following way:

  1. 1.1.0
  2. 1.5.9-beta
  3. 1.5.9
  4. 2.0.0-alpha
  5. 2.0.0

All versions of version-parser with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
symfony/polyfill-php80 Version >=v1.26.0
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 mistralys/version-parser contains the following files

Loading the files please wait ....