如何强制Composer下载本地软件包? [英] How to force Composer to download a local package?

查看:104
本文介绍了如何强制Composer下载本地软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们具有以下目录结构,我们假设 my-package 在Packagist上也存在:

Let's say we have the following directory structure, we assume my-package also exists on Packagist:

- apps
\_ my-app
  \_ composer.json
- packages
\_ my-package
  \_ composer.json

要添加 my / package 作为my-app的依赖项,文档指出我们可以使用以下配置:

To add my/package as a dependency of my-app, the documentation states we can use the following configuration:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }
}

但是,当我 composer更新时,依存关系仍然是从Packagist下载的。因此,我禁用了Packagist.org:

However when I composer update, the dependency is still downloaded from Packagist. So, to see, I disabled Packagist.org:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package",
            "packagist.org": false
        }
    ],
    "require": {
        "my/package": "*"
    }
}

我用 composer clearcache 清除了缓存,删除了 my / package composer一起删除我/软件包,并再次与 composer一起安装,需要我/软件包--prefer-source (我不明白-prefer-source 是否仅用于vcs)。下载的软件包仍然不是本地软件包。如何强制作曲家使用本地的?

I cleared the cache with composer clearcache, removed my/package with composer remove my/package and installed it again with composer require my/package --prefer-source (I didn't understand if --prefer-source is for vcs only). The downloaded package is still not the local one. How to force composer to use the local one?

推荐答案

"require": {
    "my/package": "*"
}

如果<在code> VCS 或 path 存储库类型中,您需要指定所请求软件包的版本。因此,不要像现在那样使用 * ,而是使用 @dev

In case of VCS or path repository types, you need to specify version of the package you request. So instead of using *, as you have currently, use @dev:

"require": {
    "my/package": "@dev"
}

这篇关于如何强制Composer下载本地软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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