我想安装 doctrine/dbal
存储库,其中包含 tests
和 docs
文件夹。但是使用 composer install
或 composer update
我找不到方法怎么办?
它们被排除在 doctrine/dbal
-> composer.json
文件中:
"archive": { "exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar"] }
有没有办法强制安装? 我认为必须有一种下载它的方法,例如在我的本地机器上运行测试。
编辑:
我也尝试过使用 require-dev
但在 composer update
之后 doctrine/dbal 中没有
包。tests
文件夹
最佳答案
无论如何,composer.json
文件中的选项 exclude
与您的问题无关。当您从 composer 包中创建存档时使用此选项。
为什么有些文件夹会被排除?
文件夹 /docs
和 /tests
被排除在 .gitattributes
文件中:
/tests export-ignore
/docs export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.travis.yml export-ignore
build.properties export-ignore
build.xml export-ignore
phpunit.xml.dist export-ignore
run-all.sh export-ignore
composer.lock export-ignore
那么我怎样才能下载它们呢?
首先,当您composer install
或composer update
时,composer 可以从两个不同的来源获取数据:
Dist: The dist is a packaged version of the package data. Usually a released version, usually a stable release.
Source: The source is used for development. This will usually originate from a source code repository, such as git. You can fetch this when you want to modify the downloaded package.
Packages can supply either of these, or even both. Depending on certain factors, such as user-supplied options and stability of the package, one will be preferred.
Composer 的默认值
当你的 Composer 在默认配置下使用stable
包并且首选安装是dist
。
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
然后 composer 从 github 下载一个 zip 文件,该文件是使用 .gitattributes
中定义的过滤器创建的。这使得 Composer 更快。
使 composer 从源代码下载
如果您喜欢资源,您有两个选择。
- 制作
"preferred-install": "source"
- 在
composer update
上使用--prefer-source
选项
它们都使 Composer 对所有 包使用source
。
如果你只想拥有 doctrine/dbal
的源代码而不是所有包的源代码,那么使用:
composer update doctrine/dbal --prefer-source
注意事项
您必须删除 /vendor
文件夹中的 doctrine/dbal
文件夹(或您希望从源代码更新的任何文件夹),如果它已经存在才能获取它重新安装。
关于php - 如何通过 Composer 下载排除的路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28169938/