Does it make any difference between updating by composer.phar self-update and just replacing composer.phar with a newer version (e.g. with curl -sS https://getcomposer.org/installer | php)?
I'm asking this since composer.phar self-update makes some problems and I thougt then I will just download a new version. But I'm also wondering if it's just about replacing one single file, why is self-update implemented as well? What is the benefit of using this routine?
The process is different, but the result is the same. Using the most recent composer phar file.
The benefits are in easier access. To update, I just type composer like I always do when install/update/require new packages, then add self-update.
Also when I forget the command, just run composer and command list is printed.
One more reason is it's common command in PHAR file ecosystem. PHPUnit, PhpCsFixer and many other have the same command.
Related
Good day, I would like to ask some help, had a problem on composer update.
Here is the picture
but when I check using php -v, it says the php version is 7.1.21.
I really don't know what to do.
Try php composer.phar update.
Your "composer" could be an alias and it's probably pointing to a php 7.0 installation. Check using alias composer
What is the difference between composer and composer.phar?
Example:
composer install
composer.phar install
Is there a reason why I keep seeing code writen using composer.phar all the time when composer does the same?
There is no difference - composer.phar is the executable and composer can be an alias or symlink for it, depending on the way you've installed composer. As rob006 pointed out, there can be multiple ways to install composer: the official documentation at https://getcomposer.org/doc/00-intro.md#globally recommends to move the downloaded PHAR file to /usr/local/bin/composer which will make it callable through composer for all users of your system.
If you would move the file to another destination, like /usr/local/bin/composer.phar, the same composer binary would be available under that different command composer.phar.
And finally, if you would not have the chance to install composer globally, you could put it under either name in any local place
I've installed Composer on a shared-host (hostgator) following this guide:
https://laravel.io/forum/02-13-2014-how-to-install-laravel-on-a-hostgator-shared-server
It was installed using this command:
curl -sS https://getcomposer.org/installer | php
When I try to run composer I get the message "/home2/georger/composer.phar: no such file or directory" although the file does exist, I can open it. Other questions that deal with this suggest moving it to /usr/local/bin but that's not an option for me.
As outlined in the installation instructions, you will need to pass it to the php interpreter:
$ php composer.phar
Alternatively, you might want to reconsider whether you really want to execute composer in a production environment or rather execute it during the deployment and then deploy the artifacts. In other words, you probably want to run composer install on the machine from which you want to deploy to the production system, and then synchronize files from there to the production system, for example, using rsync.
For reference, see https://getcomposer.org/doc/00-intro.md.
Normally I do install Laravel 5.1 by following this command regarding to documentation:
composer create-project laravel/laravel --prefer-dist
It works fine.
But I read in the documentation under "Via Laravel Installer" also it is possible to install via Laravel Installer, which is much faster than installing via Composer:
laravel new blog
But to use this method I need to run following command once:
composer global require "laravel/installer=~1.1"
When I do run it I get following errors many times
Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks
is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks()
instead in
phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Package/Version/VersionParser.php:226
after many line of same error ./composer.json has been updated appears and it continues with the same line of errors, it ends with following
Loading composer repositories with package information Updating
dependencies (including require-dev) Nothing to install or update
Generating autoload files
What is wrong with it? Any idea or solution.
My environment: Windows 10, GitBash and cmder console.
Update of composer, I did ran composer self-update also
Snapshot of console
EDIT:
Note, I can confirm after solving the issue that the installation via Laravel Installer method is faster than composer.
The Composer Assets Plugin you've installed locally is using a deprecated method of Composer. The plugin is already fixed, so run composer global update to get the latest versions with the bug fix. After it, you should be able to run the command succesfully.
If this doesn't work (as you might get the same error running the previous command), try removing the global vendor directory. When running any global Composer command, it outputs something like "Changed current directory to XXX". Remove the XXX/vendor directory and then try running the command.
In addition to #WouterJ answer.
Worst case if the steps provided by #WouterJ did not work, you could manage to uninstall and reinstall composer for windows.
When done, run composer global update to be sure to get latest updates, if there was.
Then run composer global require "laravel/installer=~1.1" and it should works.
Remember to update your windows environment path C:\Users\UserName\AppData\Roaming\Composer\vendor\bin
When I try to do:
$ sudo php composer.phar update
I get this warning:
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.
When I type:
$ sudo php composer.phar self-update
$ sudo php composer.phar update
the warning disappear, but the next time I want to execute the same command (not after 30 days), the warning comes again. How can I solve it?
My guess is that something else overwrites your composer.phar with an old copy. If the self-update process was failing, then you would still see the warning when doing an update right after. If you don't then something must be happening in the meantime.
You can use php composer.phar -V to see the exact version of the phar you have. You could check after a self-update and check after a while again to see if the version changed. Maybe it's checked out in git or you have a build process reverting it or something?