I am trying to update Composer without any luck!
What I have tried:
$ composer self-update
[InvalidArgumentException]
Command "self-update" is not defined.
$ sudo -H composer self-update
[InvalidArgumentException]
Command "self-update" is not defined.
$ 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.
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."
How can I fix this issue?
My PHP version is:
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
My composer version is:
composer --version
Composer version #package_branch_alias_version# (#package_version#)
#release_date#
As Waqleh said, you have to uninstall PHP Composer and install it again. First, execute:
sudo apt-get remove composer
Then, execute these commands. The checksum here is for Composer 1.10.13, but you'll get the newest Composer (2.0.4 at the moment of editing this answer) when running the first line, so be sure to check in https://getcomposer.org/download/:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { 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 file composer.phar to a directory that is in your path (from Installation - Linux / Unix / macOS):
sudo mv composer.phar /usr/local/bin/composer
And execute composer from any directory. That's all!
PS: If you're using PhpStorm (or maybe other IDEs), you'll have to close it and open it again.
Since I posted my answer, I have learnt a new easier way to install Composer programmatically: How do I install Composer programmatically?
Old Answer:
As per #JimL comment, I was able to self update Composer by:
Uninstalling Composer from the package manager (apt).
I installed it according to the official documentation
Now it works as expected.
Install the latest version:
Remove your current Composer version, for example Ubuntu/Debian:
sudo apt-get remove composer
Now, head to https://getcomposer.org/download/ and paste the script in your command line. This ensures that you get the latest version of Composer (as time of writing: v2.0.7).
Like this:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { 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 there isn't any need to use the sudo prefix:
composer self-update
It worked for me (linux, Ubuntu 20.04):
sudo apt-get remove composer
sudo apt-get update
sudo apt-get install curl
sudo curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
If you have an old version of Composer you need to follow these commands:
composer -V
sudo apt remove composer
cd /tmp
wget http://getcomposer.org/download/1.10.5/composer.phar
php composer.phar -V
sudo mv composer.phar /usr/bin/composer
sudo chmod 750 /usr/bin/composer
composer -V
You can specify the installation directory and filename while setting up PHP Composer - php composer-setup.php like so:
sudo php composer-setup.php --install-dir=/usr/bin --filename=composer
Already there are many answers, Would like to share my experience with this.
I am using Ubuntu 20.04, and My previous Composer version was Composer 2.0.11 and my Project requirement was Composer 2.1.15.
I didn't had to remove anything, I simply used the following command and it worked fine for me :)
I've installed Homebrew and it saves me a lot.
Install brew and then brew install composer to install Composer.
composer 2 on debian :
cd /usr/src
sudo apt-get install curl php7.2-cli
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
chmod 777 composer
nano ~/.bashrc
add : PATH=$PATH/usr/local/bin/
source ~/.bashrc
verify :composer -v
Composer self-update may not work for others and using the documentation from the composer may be confusing for some. The following steps may help reinstall the composer to solve the problem.
#update the package manager
sudo apt update
#install the required packages
sudo apt install php-cli unzip
#retrieve the installer
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
#obtain the latest hash from the Composer page
HASH=`curl -sS https://composer.github.io/installer.sig`
echo $HASH #verify the obtained value
#verify that the installation script safety
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
#installing composer globally
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#test your installation
composer
That's it. Credit: Erika Heidi
Install the latest Composer by the following steps:
Uninstalling Composer
sudo apt-get remove composer
Run following commands
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
Install Composer in the /usr/bin directory to run Composer from anywhere
sudo php composer-setup.php --install-dir=/usr/bin --filename=composer
Remove the installer
php -r "unlink('composer-setup.php');"
To check or self update
composer self-update
Related
This question already has answers here:
How to downgrade or install a specific version of Composer?
(7 answers)
Closed 1 year ago.
I want to install old version of composer. My commands are:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --version=1.4.1
php -r "unlink('composer-setup.php');"
But it didn't install composer. I check with the command composer -v but unfortunately it didn't work. How can I do this?
These commands will install composer binary in composer.phar file in current working directory. You may try to verify this by running php composer.phar -v command. composer command will most like point to some global installation in your system - you need to move new binary to correct place, so it could be recognized as global command (see docs):
mv composer.phar /usr/local/bin/composer
If you have already Composer installed, you should able to use self-update command to downgrade to any version:
composer self-update 1.4.1
or
sudo -H composer self-update 1.4.1
If you came here searching for downgrading from composer 2.0 to 1.0
composer self-update --1
Curl can be used to download a specific version:
curl -O "https://getcomposer.org/download/1.10.17/composer.phar"
chmod a+x composer.phar
sudo mv composer.phar /usr/local/bin/composer
If you have installed composer v2, and want to install composer v1 in addition you can do:
wget https://getcomposer.org/composer-1.phar
chmod a+x composer-1.phar
sudo mv composer-1.phar /usr/local/bin/composer1
And use composer1 on old projects:
cd <OLD-PROJECT>
composer1 install
I get the error when i run composer self-update on Windows 10
Here is the full error message
composer self-update
Updating to version 1.8.4 (stable channel).
Downloading (100%)
[RuntimeException]
SHA384 is not supported by your openssl extension, could not verify the phar file integrity
I am running PHP 7.3.2
What could be the problem?
Remove Your older versions and install the latest version of Composer,
Remove Your older version:
sudo rm -f /usr/local/bin/composer
Download the installer:
sudo curl -s https://getcomposer.org/installer | php
Move the composer.phar file:
sudo mv composer.phar /usr/local/bin/composer
Manually update the composer:
wget -cO - https://getcomposer.org/composer-stable.phar > /usr/local/bin/composer
Check the installed composer version:
composer --version
The error means you are using composer of version 1.7.2or below.
You have to uninstall composer and then install a composer version 1.7.3 and above.
I've just experienced the same issue on my Windows machine. I'd just downloaded and installed Composer from https://getcomposer.org/download/ and when I tried to run php composer-setup.php it failed with "SHA384 is not supported by your openssl extension".
The solution that worked for me was to perform the command line install (documented on the same site). Visit https://getcomposer.org/download/ to get the latest SHA.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c5b9b6d368201a9db6f74e2611495f369991b72d9c8cbd3ffbc63edff210eb73d46ffbfce88669ad33695ef77dc76976') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
you can download latest version from https://getcomposer.org/ and just replace the file composer.phar in your composer folder, in my machine this is installed in windows at C:\composer
Solution 1:
Manually update the composer(Uninstall and install)
Solution 2:
The error means you are using composer version 1.7.2 or below. Uninstall composer and then install a composer version 1.7.3 and above.
or
composer self-update --rollback and run composer self-update.
I'm trying to install Magento 2.1 using PHP composer.
http://idroot.net/tutorials/how-to-install-php-composer-on-centos-7/
I found the url above to install PHP composer for Centos 7.
on step 2 it failed:
curl -sS https://getcomposer.org/installer | php
this is the error I get
"curl: (6) Could not resolve host: php; Name or service not known
Thanks for the help guys!
wget https://getcomposer.org/composer.phar
chmod +x composer.phar
mv composer.phar /usr/local/bin/composer
Already tried with composer's documentation?
This method?
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Or just tried with the download page:
What don't you use yum instead of manual installation?
Use follow command:
yum install php71w-composer
you can replace php71w with other version as you like, such as php55w is php 5.5, php56w is php 5.6, php70w is php 7.0 and so on.If you meet the error message like "package php71w-composer not found", install webtatic repository follow by this.
I'm trying to get the Laravel PHP framework installed and for that I need to install Composer. However I'm getting stuck there. I installed it before for Symfony but I couldn't get it to work so I think I deleted it.
When I open the terminal on Mac and enter one of the commands for installing composer like:
curl -sS https://getcomposer.org/installer | php
I get:
-bash: php: command not found
curl: (23) Failed writing body (0 != 1635)
Why is this?
You can install it via Brew.
First, install Brew;
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then you can use Brew to install Composer;
brew install composer
That's it, it's now installed. You can verify this by running composer --version
download file from https://getcomposer.org/installer
execute the file
sudo php installer
and move the file
mv composer.phar /usr/local/bin/composer
Here it is:
curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
First install brew if not installed in Mac:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update brew and install php and composer.
$ brew update
$ brew install php
$ brew install composer
Verify by checking version:
$ composer -V
I hope it helps.
try
~ which php
/usr/bin/php
curl -sS https://getcomposer.org/installer | /usr/bin/php
just open your terminal and follow this steps,
here odbase is username of my mac.
cd /Users/odbase/Downloads
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar
mv composer.phar /usr/local/bin/composer
(if this produce error please run with prefix sudo. {sudo mv composer.phar /usr/local/bin/composer})
installed for check
cd /usr/local/bin
ls
I deleted some files that I should not have deleted. Did a repair install of OS X and now it works.
I downloaded the project.
My task to run this project through the xampp server.
They told me to install composter to the server.
I downloaded the project into htdocs/mysite/
I install composer
C:\bin>php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
He called through С:/xamppp/php/php composer.phar
When I run project Dependencies are not tightened(yii,...)
when I
С:/xamppp/php/php composer.phar create project C:/...htdocs/mysite/
Error:InvalidArgumentExeption
Cannot find project with stability stable
My answer may not be relevant to OP question for anyone looking to install composer
Linux - Ubuntu
sudo apt-get install composer
Or ..
Manual installation based on getcomposer.org
#!/usr/bin/env bash
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 --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
run these command in a bash file or one by one.
Or ..
# this answer is copied and not tested
curl -s http://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/
If I've read this correctly, are you trying to install yii?
If so, this guide should help:
http://www.yiiframework.com/wiki/392/creating-yii-applications-with-composer/
It has a link to a sample Github project too.
Get latest stable version of composer
wget https://getcomposer.org/download/latest-stable/composer.phar
Move to bin
sudo mv composer.phar /usr/bin/composer