php 无法自我更新作曲家?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37772798/
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
Unable to self-update composer?
提问by Waqleh
I am trying to update composer with no luck!
我正在尝试更新作曲家,但没有运气!
What I have tried:
我尝试过的:
$ composer self-update
[InvalidArgumentException]
Command "self-update" is not defined.
[InvalidArgumentException]
命令“自我更新”未定义。
$ sudo -H composer self-update
[InvalidArgumentException]
Command "self-update" is not defined.
[InvalidArgumentException]
命令“自我更新”未定义。
$ sudo apt-get install composer
Reading package lists... Done Building dependency tree Reading state information... Done composer is already the newest version. The following packages were automatically installed and are no longer required: libntdb1 linux-headers-4.2.0-30 linux-headers-4.2.0-30-generic linux-image-4.2.0-30-generic linux-image-extra-4.2.0-30-generic python-ntdb Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
正在阅读包列表...完成构建依赖树阅读状态信息...完成 composer 已经是最新版本。以下软件包已自动安装,不再需要: libntdb1 linux-headers-4.2.0-30 linux-headers-4.2.0-30-generic linux-image-4.2.0-30-generic linux-image-extra- 4.2.0-30-generic python-ntdb 使用 'apt-get autoremove' 删除它们。0 升级,0 新安装,0 删除,10 未升级。
I am trying to self-update composer because I am facing the following each time I try:
我正在尝试自我更新作曲家,因为每次尝试时我都面临以下问题:
$ composer update
Loading composer repositories with package information Updating dependencies (including require-dev) [RuntimeException]
Could not load package rmrevin/yii2-fontawesome in http://packagist.org: [UnexpectedValueException] Could not parse version constraint v4.1 .: Invalid version string "v4.1."
[UnexpectedValueException]
Could not parse version constraint v4.1.: Invalid version string "v4.1."
使用包信息
加载 Composer存储库更新依赖项(包括 require-dev) [RuntimeException]无法在http://packagist.org 中加载包 rmrevin/yii2-fontawesome :[UnexpectedValueException] 无法解析版本约束 v4.1。:无效的版本字符串“v4.1。”
[UnexpectedValueException]
无法解析版本约束 v4.1。:无效的版本字符串“v4.1。”
Any Ideas on how to fix this issue?
有关如何解决此问题的任何想法?
My php version is:
我的 php 版本是:
php --version
PHP 5.6.11-1ubuntu3.4 (cli) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
PHP 5.6.11-1ubuntu3.4 (cli) 版权所有 (c) 1997-2015 The PHP Group Zend Engine v2.6.0,版权所有 (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev,版权 (c) 1999 -2015,由 Zend Technologies
My composer version is:
我的作曲家版本是:
composer --version
Composer version @package_branch_alias_version@ (@package_version@) @release_date@
作曲家版本@package_branch_alias_version@ (@package_version@) @release_date@
采纳答案by Waqleh
As per @JimL comment I was able to self update composer by:
根据@JimL 评论,我能够通过以下方式自我更新作曲家:
- Uninstalling Composer from the package manager (apt).
- I installed it according to the official documentation
- 从包管理器 (apt) 卸载 Composer。
- 我是按照官方文档安装的
Now it works as expected.
现在它按预期工作。
回答by Manolo
As @Waqleh said, you have to uninstall composer and install it again. First execute:
正如@Waqleh 所说,您必须卸载 Composer 并重新安装。首先执行:
sudo apt-get remove composer
sudo apt-get remove composer
Then, execute these commands (from https://getcomposer.org/download/) (checksum for 1.10.1):
然后,执行这些命令(来自 https://getcomposer.org/download/)(1.10.1 的校验和):
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Now move composer.phar to a directory that is in your path (fom https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx):
现在将 composer.phar 移动到您路径中的目录(来自https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx):
sudo mv composer.phar /usr/local/bin/composer
And execute composer
from any directory. That's all!
并composer
从任何目录执行。就这样!
PS: If you're using PHPStorm (or maybe other IDE's) you'll have to close it and open again.
PS:如果您使用的是 PHPStorm(或其他 IDE),则必须关闭它并再次打开。
回答by A1Gard
install the latest version:
安装最新版本:
remove the composer: for example ubuntu/debian :
删除作曲家:例如 ubuntu/debian :
sudo apt-get remove composer
install manual:
安装手册:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
after some time passed, you can update and no need to use sudoprefix:
经过一段时间后,您可以更新而无需使用sudo前缀:
composer self-update
回答by M. Inam
I've installed brew and it saves me a lot.
Install brew then brew install composer
to install the composer.
我已经安装了 brew,它为我节省了很多。安装 brew 然后brew install composer
安装作曲家。