承接 ergebnis/version 相关项目开发

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

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

ergebnis/version

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 currently supports the following PHP versions:

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

Security Policy

This project has a security policy.

License

This project uses the MIT license.

Social

Follow @localheinz and @ergebnis on Twitter.

ergebnis/version 适用场景与选型建议

ergebnis/version 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.71k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2023 年 12 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「version」 「semantic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ergebnis/version 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ergebnis/version 我们能提供哪些服务?
定制开发 / 二次开发

基于 ergebnis/version 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-24