作曲家需要本地包装 [英] Composer require local package

查看:85
本文介绍了作曲家需要本地包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个正在共同开发的库[Foo和Bar],但从技术上讲它们仍然是分开的.以前,我刚刚将自动加载器重新定义为"Foo\\": "../Foo/src",但是现在我已经向Foo添加了Guzzle依赖项,Bar翻转了它的盖子,因为它不是其依赖项之一.

I've got a couple of libraries [Foo and Bar] that I'm developing in concert, but are still technically separate things. Previously I've just re-defined the autoloader to like "Foo\\": "../Foo/src", but now that I've added a Guzzle dependency to Foo, Bar flips it's lid because it's not one of its dependencies.

目录结构:

/home/user/src/
    Foo/
        src/
            FooClient.php
        composer.json
    Bar/
        src/
            BarClient.php
        composer.json

理论上的自动加载语句:[在Bar/composer.json中]

Theoretical Autoload Statement: [in Bar/composer.json]

"require": {
    "local": "../Foo/composer.json"
}

示例代码:

require('vendor/autoload.php');

$f = new \Bar\BarClient(new \Foo\FooClient());

如何在不设置本地Composer存储库的情况下解决此问题?我想将它们作为单独的软件包进行维护,只是一个软件包需要另一个软件包,并因此处理另一个软件包的依赖关系.

How can I resolve this without setting up a local Composer repo? I want to maintain these as separate packages, just that one requires the other, and therefor processes the other's dependencies.

由于信息狂,我已经完成了以下工作:

Thanks to infomaniac I've done the following:

初始化git repo:

Initialized the git repo:

cd ~/src/Foo && git init && echo -e "vendor\ncomposer.lock" > .gitignore && git add ./ && git commit -m "Initial Commit"

添加了作曲家配置:

"require": {
    "sammitch/foo": "dev-master"
},
"repositories": [{
    "type": "vcs",
    "url": "/home/sammitch/src/Foo"
}],

然后composer update

推荐答案

您可以使用Composer的存储库功能

You can use Composer's repositories feature

https://getcomposer. org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

在磁盘上指定文件路径,而不是使用http格式.

Instead of using the http format, specify a file path on disk.

这篇关于作曲家需要本地包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆