简体   繁体   English

作曲家:循环依赖中的版本冲突

[英]Composer: Version conflicts in circular dependency

First of all, I know this setup is stupid but this is what we're stuck with 🤷‍♂️ 首先,我知道这种设置很愚蠢,但这就是我们被困住的地方

We build websites with our company framework. 我们使用公司框架构建网站。 The website contains some classes that the framework directly accesses. 该网站包含该框架直接访问的一些类。 This means we have a circular dependency. 这意味着我们具有循环依赖关系。 This was not a problem until now. 到目前为止,这不是问题。

These are slimmer versions of our composer.json s: 这些是我们composer.json的苗条版本:

Framework : 框架

The framework just defines some other 该框架只定义了其他一些

{
    "name": "company/framework",
    "type": "library",
    "require": {
        ...
    }
}

Website : 网站

{
    "name": "company/website",
    "require": {
        "company/framework": "^4.3",
        ...
    }
}

Very simple, framework is a dependency of website . 很简单, frameworkwebsite的依赖项。

Now, I'm trying to setup a CI server with static analysis for the framework . 现在,我正在尝试为framework设置带有静态分析的CI服务器。 As mentioned, the framework requires some files in the website for static analysis to succeed. 如前所述,该framework需要website一些文件才能成功进行静态分析。

The new company/framework/composer.json file looks like this: 新的company / framework / composer.json文件如下所示:

{
    "name": "company/framework",
    "type": "library",
    "require": {
        "company/website": "^4.3",
        ...
    }
}

This works fine when testing a tagged framework version. 在测试带标记的framework版本时,这可以很好地工作。 Whenever we're in a develop branch Composer will fail since website requires a stable ^4.3 version of the framework but this is a develop branch. 每当我们进入开发分支机构时,Composer都会失败,因为website需要稳定的^4.3版本的框架,但这是一个开发分支机构。

Is there any way I can work around this? 有什么办法可以解决这个问题?

Extract the classes that are needed to test the framework into a separate package. 将测试框架所需的类提取到单独的程序包中。

Framework requires that package. 框架需要该软件包。

Website requires that package. 网站需要该软件包。 And requires Framework (which also requires that package). 并需要Framework(也需要该包)。

Voila, you transformed a circular dependency into a linear graph. 瞧,您将循环依赖关系转换为线性图。

Add semantic versioning to this approach, and you will never have serious problems - or spot them pretty soon. 向这种方法添加语义版本控制,您将永远不会遇到严重的问题-或很快发现它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM