php Composer 从缓存加载

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22700728/
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 16:11:32  来源:igfitidea点击:

Composer loading from cache

phpcomposer-php

提问by Tarik

i ran in a problem using composer for installing/uninstalling some dependencies in laravel which coming back after deleting them from composer.jsonand deleting their vendor folder, i initially used dflydev's markdown package but now i wanted to change it to michelf's php-markdown, but i cant uninstall the old one since it comes back loaded from cache, which i checked at AppData\Roaming\Composerand is empty, any clue on to why this is happening?

我在使用 composer 安装/卸载 laravel 中的一些依赖项时遇到了问题,这些依赖项在从composer.json它们的供应商文件夹中删除并删除它们后又回来了,我最初使用的是 dflydev 的 markdown 包,但现在我想将其更改为 michelf 的 php-markdown,但我不能卸载旧的,因为它从缓存中加载回来,我检查过AppData\Roaming\Composer它是空的,任何关于为什么会发生这种情况的线索?

  - Installing dflydev/markdown (dev-master dee1f7a)
    Loading from cache

回答by Atish Goswami

You can use the following command to clear the cache irrespective of the OS you are on:

无论您使用何种操作系统,您都可以使用以下命令清除缓存:

php composer.phar clear-cache

or if composer is installed globally

或者如果 Composer 是全局安装的

composer clear-cache

Hope this helps

希望这可以帮助

回答by zwacky

composer caches packages under vendor/packagename convention. So you shouldn't run into any issue, just because the packagename is used in another vendor's package.

composer 在供应商/包名约定下缓存包。所以你不应该遇到任何问题,仅仅因为在另一个供应商的包中使用了包名。

the cache locations are:

缓存位置是:

  • windows: %LOCALAPPDATA%\Composer\files\vendor\packagename
  • linux: ~/.composer/cache/files/vendor/packagename
  • windows: %LOCALAPPDATA%\Composer\files\vendor\packagename
  • linux: ~/.composer/cache/files/vendor/packagename

回答by monsur.hoq

If you want to clear all packages cache, please try following:

如果要清除所有包缓存,请尝试以下操作:

$ composer clearcache

Or to just clear one or a few packages:

或者只清除一个或几个包:

$ composer clearcache packagename1 packagename2 ...
$ composer clearcache packagename1 packagename2 ...

You can also use clear-cachewhich is an alias for clearcache.

您还可以使用clear-cachewhich 作为clearcache.

Source : https://blog.liplex.de/clear-composer-cache/

来源:https: //blog.liplex.de/clear-composer-cache/

回答by Mostafa

In some cases (for example OpenSuse 42.1) all user cache are puts in:

在某些情况下(例如 OpenSuse 42.1)所有用户缓存都放在:

~/.cache/

For the composer, the same as other applications, the cache path is:

对于composer,和其他应用一样,缓存路径为:

~/.cache/composer/

So, just remove this folder as follow:

因此,只需按如下方式删除此文件夹:

rm -fR ~/.cache/composer

回答by Sir Mbuki

run the following command

运行以下命令

rm -rf ~/.composer/cache*

if Permission denied add sudo

如果权限被拒绝添加 sudo

回答by Darvanen

Don't edit your composer.jsonfile manually to remove a package - it will remain in composer.lock.

不要composer.json手动编辑您的文件以删除包 - 它会保留在composer.lock.

Use composer removeto delete the old package then composer requireto install the replacement.

使用composer remove删除旧包然后composer require安装替换。

回答by Phan Van Linh

On Window, I see the composer cache file located in
C:\Users\{your_user}\AppData\Local\Composer\files

Window 上,我看到 Composer 缓存文件位于
C:\Users\{your_user}\AppData\Local\Composer\files

enter image description here

在此处输入图片说明

It stores ZIP files. The below image has 2 Zip files because I have downloaded 2 versions of monolog (1.0.1 and 1.0.2) enter image description here

它存储 ZIP 文件。下图有 2 个 Zip 文件,因为我下载了 2 个版本的 Monolog(1.0.1 和 1.0.2) 在此处输入图片说明

To remove the cache, simply delete the Zip file or folder.

要删除缓存,只需删除 Zip 文件或文件夹。