Hello

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-20-04

how to upgrade to version 2 ??
command, composer self-update –2 , is not defined !!

Also as non root user:
fileputcontents(/var/www/mywebsite/vendor/composer/autoload_classmap.php): failed to open stream: Permission denied.

Regards, Tjeu

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

In case that you’ve installed composer with apt already you might have to remove the package first and then follow the steps from the tutorial:

  • Remove the current installation:
sudo apt remove composer
  • Install the latest version:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { 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');"

Let me know how it goes.
Regards,
Bobby

  • Do it in the project dir. /var/www/mywebsite

    Example
    type: php composer.phar
    type: php composer.phar –version

    use sudo if necessary

    Example: sudo php composer.phar dump-autoload
    sudo php composer.phar install
    Continue as root/super user [yes]? yes

    vendor/composer = only root access

  • It was a big help, thanks Bobby.