Install PHP Composer on Ubuntu: Difference between revisions

From WikiMLT
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>{{ContentArticleHeader/Linux Server|toc=off}}{{ContentArticleHeader/PHP}}</noinclude>
<noinclude>{{ContentArticleHeader/Linux Server|toc=off}}{{ContentArticleHeader/PHP}}</noinclude>


==Install Composer via Apt==
== Update 2022 ==
<syntaxhighlight lang="shell" line="1">
'''The instructions below may be deprecated! Because the instructions will change with every version of the installer... Instead, please visit the page https://getcomposer.org/download/ and follow the steps provided there!'''
sudo apt update && \
sudo apt install composer


If Composer is already installed on your system - i.e. <code>/usr/local/bin/composer</code> - you can update it by the following command command :<syntaxhighlight lang="shell" line="1">
sudo composer self-update
</syntaxhighlight><syntaxhighlight lang="bash">
Upgrading to version 2.5.1 (stable channel).
Use 'composer self-update --rollback' to return to version 2.4.4
</syntaxhighlight>
</syntaxhighlight>
Depending on the version of the OS the Composer's version could be relatively old.


== Install the latest version of Composer manually ==
== Install the latest version of Composer ==
<syntaxhighlight lang="shell" line="1">
<syntaxhighlight lang="shell" line="1" class="code-continue mlw-shell-gray">
sudo apt update
sudo apt update
sudo apt install php-cli unzip
sudo apt install php-cli unzip
</syntaxhighlight><syntaxhighlight lang="shell" line="1">
</syntaxhighlight>
<syntaxhighlight lang="shell" line="1">
cd ~/tmp && \
cd ~/tmp && \
curl -sS https://getcomposer.org/installer -o composer-setup.php && \
curl -sS https://getcomposer.org/installer -o composer-setup.php && \
Line 23: Line 26:


== References ==
== References ==
*Composer - a dependency manager for PHP:  [https://getcomposer.org/download/ getComposer.org/download]
*Composer - a dependency manager for PHP: [https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md geComposer.org/doc/faqs/how-to-install-composer-programmatically]
*Digital Ocean: [https://www.digitalocean.com/community/tutorials/how-to-install-composer-on-ubuntu-20-04-quickstart <nowiki>How To Install Composer on Ubuntu 20.04 [Quick-start]</nowiki>]
*Digital Ocean: [https://www.digitalocean.com/community/tutorials/how-to-install-composer-on-ubuntu-20-04-quickstart <nowiki>How To Install Composer on Ubuntu 20.04 [Quick-start]</nowiki>]


*Digital Ocean: [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-20-04 How To Install and Use Composer on Ubuntu 20.04]
*Digital Ocean: [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-20-04 How To Install and Use Composer on Ubuntu 20.04]
<noinclude>
==Install Composer via Apt==
<div id="devStage">
<syntaxhighlight lang="shell" line="1">
sudo apt update && \
sudo apt install composer
 
</syntaxhighlight>
'''Depending on the version of the OS the Composer's version could be relatively old.'''<noinclude>
<div id='devStage'>
{{devStage  
{{devStage  
  | Прндл  = PHP
  | Прндл  = PHP
  | Прндл1 = Linux Server
  | Прндл1 = Linux Server
  | Стадий = 3
  | Стадий = 6
  | Фаза  = Разработване
  | Фаза  = Утвърждаване
  | Статус = Разработван
  | Статус = Утвърден
  | ИдтПт  = Spas
  | ИдтПт  = Spas
  | РзбПт  = {{REVISIONUSER}}
  | РзбПт = Spas
| АвтПт  = Spas
| УтвПт = {{REVISIONUSER}}
  | ИдтДт  = 28.07.2022
  | ИдтДт  = 28.07.2022
  | РзбДт  = {{Today}}
  | РзбДт = 28.07.2022
| АвтДт  = 28.07.2022
| УтвДт = {{Today}}
  | ИдтРв  = [[Special:Permalink/29556|29556]]
  | ИдтРв  = [[Special:Permalink/29556|29556]]
  | РзбРв  = {{REVISIONID}}
  | РзбРв = [[Special:Permalink/29561|29561]]
| АвтРв  = [[Special:Permalink/29562|29562]]
| УтвРв = {{REVISIONID}}
}}
}}
</div>
</div>
</noinclude>
</noinclude>

Latest revision as of 14:11, 7 January 2023

Up­date 2022

The in­struc­tions be­low may be dep­re­cat­ed! Be­cause the in­struc­tions will change with every ver­sion of the in­staller… In­stead, please vis­it the page https://​getcomposer​.org/​d​o​w​n​load/ and fol­low the steps pro­vid­ed there!

If Com­pos­er is al­ready in­stalled on your sys­tem – i.e. /​​​usr/​​​local/​​​bin/​​​composer – you can up­date it by the fol­low­ing com­mand com­mand :

sudo composer self-update
Upgrading to version 2.5.1 (stable channel).
Use 'composer self-update --rollback' to return to version 2.4.4

In­stall the lat­est ver­sion of Com­pos­er

sudo apt update
sudo apt install php-cli unzip
cd ~/tmp && \
curl -sS https://getcomposer.org/installer -o composer-setup.php && \
HASH=$(curl -sS https://composer.github.io/installer.sig) && \
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { 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 && \
composer -V

Ref­er­ences

In­stall Com­pos­er via Apt

sudo apt update && \
sudo apt install composer

De­pend­ing on the ver­sion of the OS the Composer's ver­sion could be rel­a­tive­ly old.