dqkx69935 2016-10-28 09:29 采纳率: 100%
浏览 50
已采纳

在PHP Composer中,配置依赖项以安装仍与当前平台或框架兼容的最新版本的软件包

Imagine there is some framework X and modules A and B developed for this framework. Also, A depends on B (any version of B allowed). Originally, A v.10 and B v1.0 were developed for X v1.0.

B and A are released new versions periodically. This will lead to when I update A, B would also get updated. Let's assume a few years passed and now in our repository there is A of v3.0 and B of v6.0 (and both A and B are still for X v1.0).

Now we have some local installation which have remained in the original state (X, A and B are all of v1.0). So if I updated A at this point, this would end up in updating A to v3.0 and B to v6.0. But let's assume I didn't run this update before X v2.0 release.

Now framework X v2.0 gets released and it's not compatible with X v1.0. Vendor of B then released B v7.0 for X v2.0. Vendor of A, however, hasn't updated it for X v2.0 yet. The attempt to update A to v3.0 will lead to an attempt to update B to v7.0 which won't work and the upgrade procedure will be terminated.

What I wanted would be that updating A to 3.0 will lead to updating B to v6.0 as it was the last compatible version for X v1.0.

If in A there was dependency "B 1.x", this would protect me from getting issues when B v2.0 for X v2.0 comes out. However, I won't be able to get updates to B when it gets new major releases which can still be compatible with X v1.0. This means the module vendor cannot make v2.0 if it still runs on X v1.0 framework, all updates to B must be v1.x.

So I'd better have freedom to set versions to modules (incl. major versions) independently of X framework versions. I need mechanism to resolve dependencies in the way that the most recent version of dependency gets installed ONLY if it's compatible with the current environment. If it's not compatible, the most recent compatible version will be selected instead of stopping the whole process.

It is possible to "tell" Composer "Update to the latest versions which are possible under the current conditions" instead simply of "Update to the latest versions"?

  • 写回答

1条回答 默认 最新

  • dongyan2469 2016-10-28 09:47
    关注

    First of all need to understand versioning semantic. In few words:

    version: X.Y.Z

    where:

    • X: major version (breaking changes)
    • Y: minor version (features adding, must be compatible with previous versions in the same major version)
    • Z: bug fixes (must be compatible with previous versions in the same major version)

    https://getcomposer.org/doc/articles/versions.md

    So if you write:

    for example: ^1.2.3

    it will update library to the latest including new feature (e.g: 1.*.*) (but it will keep the same major version, e.g if available it will update to 1.4.5)

    ~1.2.3 is more strict and it will update only bug fixes version (e.g: 1.2.*)

    but, unfortunately not all libraries follow version semantic, so anyway you have to check update result.

    But in both cases minimal required version is: 1.2.3

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动