承接 ergebnis/version 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ergebnis/version

最新稳定版本:1.3.0

Composer 安装命令:

composer require ergebnis/version

包简介

Provides an abstraction of a semantic version.

README 文档

README

Integrate Merge Release Renew

Code Coverage

Latest Stable Version Total Downloads Monthly Downloads

This project provides a composer package with an abstraction of a semantic version.

Installation

Run

composer require ergebnis/version

Usage

This project comes with the following components:

Version

Create a Version from a string

<?php declare(strict_types=1); use Ergebnis\Version; $version = Version\Version::fromString('1.2.3-alpha+build.9001'); echo $version->toString(); // 1.2.3 echo $version->major()->toString(); // 1 echo $version->minor()->toString(); // 2 echo $version->patch()->toString(); // 3 echo $version->preRelease()->toString(); // alpha echo $version->buildMetaData()->toString(); // build.9001

Bump a Version

<?php declare(strict_types=1); use Ergebnis\Version; $version = Version\Version::fromString('1.2.3'); $one = $version->bumpMajor(); echo $one->toString(); // 2.0.0 $two = $version->bumpMinor(); echo $two->toString(); // 1.3.0 $three = $version->bumpPatch(); echo $three->toString(); // 1.2.4

Bump a Version with PreRelease

<?php declare(strict_types=1); use Ergebnis\Version; $version = Version\Version::fromString('1.2.3-alpha'); $one = $version->bumpMajor(); echo $one->toString(); // 2.0.0 $two = $version->bumpMinor(); echo $two->toString(); // 1.3.0 $three = $version->bumpPatch(); echo $three->toString(); // 1.2.3

Bump a Version with BuildMetaData

<?php declare(strict_types=1); use Ergebnis\Version; $version = Version\Version::fromString('1.2.3+build.9001'); $one = $version->bumpMajor(); echo $one->toString(); // 2.0.0 $two = $version->bumpMinor(); echo $two->toString(); // 1.3.0 $three = $version->bumpPatch(); echo $three->toString(); // 1.2.4

Compare a Version with another Version

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Version::fromString('1.2.3-alpha'); $two = Version\Version::fromString('1.2.3'); $three = Version\Version::fromString('1.2.4'); $four = Version\Version::fromString('1.2.4+build.9001'); $one->compare($two); // -1 $one->compare($one); // 0 $three->compare($one); // 1 $one->isSmallerThan($one); // false $one->isSmallerThan($two); // true $one->isSmallerThan($three); // true $one->isSmallerThan($four); // true $one->equals($two); // false $one->equals($one); // true $one->equals($three); // false $three->equals($four); // true $one->isGreaterThan($one); // false $two->isGreaterThan($one); // true $three->isGreaterThan($one); // true $four->isGreaterThan($one); // true

Major

Create a Major from an int

<?php declare(strict_types=1); use Ergebnis\Version; $major = Version\Major::fromInt(1); echo $major->toString(); // 1

Create a Major from a string

<?php declare(strict_types=1); use Ergebnis\Version; $major = Version\Major::fromString('1'); echo $major->toString(); // 1

Bump a Major

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Major::fromString('1'); $two = $one->bump(); echo $two->toString(); // 2

Compare a Major with another Major

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Major::fromString('1'); $two = Version\Major::fromString('2'); $one->compare($two); // -1 $one->compare($one); // 0 $two->compare($one); // 1 $one->isSmallerThan($one); // false $one->isSmallerThan($two); // true $one->equals($two); // false $one->equals($one); // true $one->isGreaterThan($one); // false $two->isGreaterThan($one); // true

Minor

Create a Minor from an int

<?php declare(strict_types=1); use Ergebnis\Version; $minor = Version\Minor::fromInt(1); echo $minor->toString(); // 1

Create a Minor from a string

<?php declare(strict_types=1); use Ergebnis\Version; $minor = Version\Minor::fromString('1'); echo $minor->toString(); // 1

Bump a Minor

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Minor::fromString('1'); $two = $one->bump(); echo $two->toString(); // 2

Compare a Minor with another Minor

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Minor::fromString('1'); $two = Version\Minor::fromString('2'); $one->compare($two); // -1 $one->compare($one); // 0 $two->compare($one); // 1 $one->isSmallerThan($one); // false $one->isSmallerThan($two); // true $one->equals($two); // false $one->equals($one); // true $one->isGreaterThan($one); // false $two->isGreaterThan($one); // true

Patch

Create a Patch from an int

<?php declare(strict_types=1); use Ergebnis\Version; $patch = Version\Patch::fromInt(1); echo $patch->toString(); // 1

Create a Patch from a string

<?php declare(strict_types=1); use Ergebnis\Version; $patch = Version\Patch::fromString('1'); echo $patch->toString(); // 1

Bump a Patch

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Patch::fromString('1'); $two = $one->bump(); echo $two->toString(); // 2

Compare a Patch with another Patch

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\Patch::fromString('1'); $two = Version\Patch::fromString('2'); $one->compare($two); // -1 $one->compare($one); // 0 $two->compare($one); // 1 $one->isSmallerThan($one); // false $one->isSmallerThan($two); // true $one->equals($two); // false $one->equals($one); // true $one->isGreaterThan($one); // false $two->isGreaterThan($one); // true

PreRelease

Create a PreRelease from a string

<?php declare(strict_types=1); use Ergebnis\Version; $preRelease = Version\PreRelease::fromString('alpha'); echo $preRelease->toString(); // alpha

Create an empty PreRelease

<?php declare(strict_types=1); use Ergebnis\Version; $preRelease = Version\PreRelease::empty(); echo $preRelease->toString(); // empty

Compare a PreRelease with another PreRelease

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\PreRelease::fromString('alpha'); $two = Version\PreRelease::fromString('rc.1'); $one->compare($two); // -1 $one->compare($one); // 0 $two->compare($one); // 1 $one->isSmallerThan($one); // false $one->isSmallerThan($two); // true $one->equals($two); // false $one->equals($one); // true $one->isGreaterThan($one); // false $two->isGreaterThan($one); // true

BuildMetaData

Create a BuildMetaData from a string

<?php declare(strict_types=1); use Ergebnis\Version; $buildMetaData = Version\BuildMetaData::fromString('build.9001'); echo $buildMetaData->toString(); // build.9001

Create an empty BuildMetaData

<?php declare(strict_types=1); use Ergebnis\Version; $buildMetaData = Version\BuildMetaData::empty(); echo $buildMetaData->toString(); // empty

Compare a BuildMetaData with another BuildMetaData

<?php declare(strict_types=1); use Ergebnis\Version; $one = Version\BuildMetaData::fromString('build.9001'); $two = Version\BuildMetaData::fromString('build.9000'); $one->equals($two); // false $one->equals($one); // true

Changelog

The maintainers of this project record notable changes to this project in a changelog.

Contributing

The maintainers of this project suggest following the contribution guide.

Code of Conduct

The maintainers of this project ask contributors to follow the code of conduct.

General Support Policy

The maintainers of this project provide limited support.

You can support the maintenance of this project by sponsoring @ergebnis.

PHP Version Support Policy

This project supports PHP versions with active and security support.

The maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.

Security Policy

This project has a security policy.

License

This project uses the MIT license.

Social

Follow @localheinz and @ergebnis on Twitter.

统计信息

  • 总下载量: 10.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固