2

The problem:

I have Entities that are and will be the same for 2 projects written in Symfony. We got an idea to share them between projects. The first idea was to use git sub-module but everyone knows that it's not the most comfortable solution. So we put them in Satis as separate git repository.

In one project I would like to edit them in application directory src/AppBundle/Entity on the other they can be downloaded into vendor directory.

The question is how to setup composer so I can work with them not in vendor directory. How the commits will look like? Is git sub-module required for this?

I've already read about "type" : "path" for repository, I've checked composer installers. Is there any other solution than symlink which comes to my mind right now?

So to sum up.

How to work with shared library in one project from app directory and on the other on vendor directory?

4

1 回答 1

0

这是对我有用的解决方案。

我已将内部库克隆到项目中。

在主项目中,我将此目录添加到 .gitignore 并在 composer.json 我添加了以下几行

"repositories": [
        {
            "type": "path",
            "url": "internal-library",
            "options": {
                "symlink": true
            }
        },
        {
            "type": "composer",
            "url": "http://our-satis"
        }
    ],

在另一个项目中,我只添加了满足存储库(实体将仅在一个项目中更改并导入到另一个项目中)。

"repositories": [
            {
                "type": "composer",
                "url": "http://our-satis"
            }
        ],

所以现在在开发中,当我做作曲家更新时,库被符号链接到供应商目录。如果我没有这个目录,它将来自 satis。因为我的目录不存在,所以在生产存储库中将从 satis 获取。我在 PSR 加载方面遇到了一些问题,但一切都按预期工作。

我希望它能帮助遇到和我一样问题的人。

于 2016-08-17T13:39:24.330 回答