Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer auto self-update

Tags:

It is frequently that every 30 days I will get this warning message:

Warning: This development build of composer is over 30 days old. It is recommended to update it by running "composer.phar self-update" to get the latest version. 

Then, I have to repeatedly do the update every 30 days. Is there anyway I can have the composer to auto update itself?

Thank you.

like image 857
user1995781 Avatar asked Jul 18 '14 02:07

user1995781


People also ask

Does composer install update?

When to install and when to update. composer update is mostly used in the 'development' phase, to upgrade our project packages. composer install is primarily used in the 'deploying phase' to install our application on a production server or on a testing environment, using the same dependencies stored in the composer.

How do I update composer globally?

For updating your Composer, you need to open the terminal (if you have a global installation) and run one of the following commands: Use composer self-update --preview to try the latest RC version (2. x). Use composer self-update --snapshot to try the latest dev build (2.


2 Answers

Composer doesn't have a feature to automatically run self-update to my knowledge. Also, running self-update by itself doesn't seem like the right way. Maybe you don't have permission? Then try using sudo, like: sudo composer self-update.

It is just a simple command, and you should only need to do it once about every 30 days. And keep Composer installed globally so you don't need to run it for each project.

like image 166
Hari K T Avatar answered Sep 20 '22 21:09

Hari K T


For versions of composer which self-update is not yet available, just run the following commands:

  1. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');". This will download the composer-setup.php file into the current working directory;
  2. php composer-setup.php. This will create the composer.phar file into the current working directory;
  3. sudo mv composer.phar `which composer` . Replace the installed composer executable (in my case /usr/bin/composer) with the one from the previous step.

After you've done this steps the sudo composer self-update will become available.

like image 27
Francisco Luz Avatar answered Sep 19 '22 21:09

Francisco Luz