php 如何强制作曲家重新安装库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19611346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 19:46:26  来源:igfitidea点击:

How to force composer to reinstall a library?

phpzend-framework2composer-php

提问by Julian

I'm using the ZF2 skeleton app and it has a .gitignore that prevents external libraries from being commited to git. While debugging I like to go and change stuff here and there in the libraries' source to learn how things work. If these were version controlled it would be very easy to revert them back to their original state.

我正在使用 ZF2 框架应用程序,它有一个 .gitignore 可以防止将外部库提交到 git。在调试时,我喜欢在库的源代码中到处更改内容,以了解事情是如何工作的。如果这些是版本控制的,则很容易将它们恢复到原始状态。

How can I force Composer to reinstall a particular framework so that I can get a fresh -unmodified- copy again?

如何强制 Composer 重新安装特定框架,以便我可以再次获得全新的未修改副本?

PS: Please don't suggest removing the .gitignore file since it's there for a reason; it prevents my third party libraries from getting into my app's repository. I can always install them during an automated deployment.

PS:请不要建议删除 .gitignore 文件,因为它存在是有原因的;它可以防止我的第三方库进入我的应用程序的存储库。我总是可以在自动部署期间安装它们。

采纳答案by Bram Gerritsen

You can use the --prefer-sourceflag for composer to checkout external packages with the VCS information (if any available). You can simply revert to the original state. Also if you issue the composer updatecommand composer will detect any changes you made locally and ask if you want to discard them.

您可以使用--prefer-sourcecomposer的标志来检出带有 VCS 信息的外部包(如果有的话)。您可以简单地恢复到原始状态。此外,如果您发出composer update命令,composer 将检测您在本地所做的任何更改,并询问您是否要丢弃它们。

Your .gitignore file is related to your root project (ZF2 skeleton) and it prevents the vendor dir (where your third party libs are) from committing to your own VCS. The ignore file is unrelated to the git repo's of your vendors.

您的 .gitignore 文件与您的根项目(ZF2 框架)相关,它会阻止供应商目录(您的第三方库所在的位置)提交到您自己的 VCS。忽略文件与供应商的 git 存储库无关。

回答by Zoran

Just clear your vendors folder

只需清除您的供应商文件夹

rm -rf vendor/*

回答by Yerke

I didn't want to delete all the packages in vendor/directory, so here is how I did it:

我不想删除vendor/目录中的所有包,所以我是这样做的:

  1. rm -rf vendor/package-i-messed-up
  2. composer installagain
  1. rm -rf vendor/package-i-messed-up
  2. composer install再次

回答by Attila Fulop

What I did:

我做了什么:

  1. Deleted that particular library's folder
  2. composer update --prefer-source vendor/library-name
  1. 删除了该特定库的文件夹
  2. composer update --prefer-source vendor/library-name

It fetches the library again along with it's git repo

它再次获取库以及它的 git repo

回答by Abdalhady Alsayad

Reinstall the dependencies. Remove the vendor folder (manually) or via rm command (if you are in the project folder, sure) on Linux before:

重新安装依赖项。之前在 Linux 上删除 vendor 文件夹(手动)或通过 rm 命令(如果您在项目文件夹中,确定):

rm -rf vendor/

composer update -v

https://www.dev-metal.com/composer-problems-try-full-reset/

https://www.dev-metal.com/composer-problems-try-full-reset/

回答by frederickjh

As user @aaracrr pointed out in a comment on another answer probably the best answer is to re-require the package with the same version constraint.

正如用户@aaracrr 在对另一个答案的评论中指出的那样,最好的答案可能是重新要求具有相同版本约束的包。

ie.

IE。

composer require vendor/package

or specifying a version constraint

或指定版本约束

composer require vendor/package:^1.0.0