How to install composer 1.6.3 on ubuntu 18.04

To install Composer 1.6.3 on Ubuntu 18.04

Composer is a dependency manager tool for PHP. The basic function of    Composer is to install and update  the libraries for your project. Composer can be used with  each individual project like Mediawiki or even  your own custom app is written in PHP. There are many open source projects and frameworks written in PHP use Composer to manage and install their packages and dependencies. This tutorial covers the method to install composer globally on Debian or Ubuntu Linux server. 

 

Installing  Composer

The installation of Composer requires the prior installation of PHP, so make sure you run the following command.

root@linuxhelp:~# apt install php -y
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
  apache2 libapache2-mod-php7.2 php-common php7.2 php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear
The following NEW packages will be installed:
  apache2 libapache2-mod-php7.2 php php-common php7.2 php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline
0 upgraded, 10 newly installed, 0 to remove and 205 not upgraded.
Need to get 3,851 kB/3,946 kB of archives.
After this operation, 17.7 MB of additional disk space will be used.
.
.
Creating config file /etc/php/7.2/apache2/php.ini with new version
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
apache2_invoke: Enable module php7.2
Setting up php7.2 (7.2.3-1ubuntu1) ...
Setting up php (1:7.2+60ubuntu1) ...
Processing triggers for ufw (0.35-5) ...

 

 

Once it is done, you need to verify the installation using the following command.

root@linuxhelp:~# php -v
PHP 7.2.3-1ubuntu1 (cli) (built: Mar 14 2018 22:03:58) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.3-1ubuntu1, Copyright (c) 1999-2018, by Zend Technologies

You can notice that ubuntu 18.04 delivers with PHP 7.2.

 

Now, you can download the composer from its official release site by making use of the following command.

root@linuxhelp:~# wget https://getcomposer.org/download/1.6.3/composer.phar
--2018-04-12 02:47:16--  https://getcomposer.org/download/1.6.3/composer.phar
Resolving getcomposer.org (getcomposer.org)... 54.36.53.46, 2001:41d0:302:1100::8:104f
Connecting to getcomposer.org (getcomposer.org)|54.36.53.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1861877 (1.8M) [application/octet-stream]
Saving to: ‘ composer.phar’ 

composer.phar                  100%[====================================================> ]   1.78M   319KB/s    in 7.5s   

2018-04-12 02:47:25 (242 KB/s) - ‘ composer.phar’  saved [1861877/1861877]

 

Before you proceed with the installation, you should rename before you install and make it an executable file.

root@linuxhelp:~# mv composer.phar composer
root@linuxhelp:~# chmod +x composer

 

Now install the package by making use the following command.

root@linuxhelp:~# ./composer

Do not run Composer as root/super user! See https://getcomposer.org/root for details

   ______

  / ____/___  ____ ___  ____  ____  ________  _____

 / /   / __ / __ `__ / __ / __ / ___/ _ / ___/

/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /

\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/

                    /_/

Composer version 1.6.3 2018-01-31 16:28:17


Usage:

  command [options] [arguments]


Options:

  -h, --help                     Display this help message

  -q, --quiet                    Do not output any message

  -V, --version                  Display this application version

      --ansi                     Force ANSI output

      --no-ansi                  Disable ANSI output

  -n, --no-interaction           Do not ask any interactive question

      --profile                  Display timing and memory usage information

      --no-plugins               Whether to disable plugins.

  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.

  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and

.

.

.lock file.

  upgrade              Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.

  validate             Validates a composer.json and composer.lock.

  why                  Shows which packages cause the given package to be installed.

  why-not              Shows which packages prevent the given package from being installed.

 

The composer has been successfully installed now, make it access globally using the following command.

root@linuxhelp:~# mv composer /usr/local/bin/

 

 

Now let us verify composer. 

root@linuxhelp:~# composer -version
Do not run Composer as root/super user! See https://getcomposer.org/root for details.  
Composer version 1.6.3 2018-01-31 16:28:17

With this, the method to install Composer 1.6.3 comes to an end.

FAQ
Q
How to check Version of the composer?
A
You can check by using this command
$ composer -V
Q
How to install Composer to a specific directory in composer?
A
By using this coomand to install

$ php composer-setup.php --install-dir=bin --filename=composer
Q
What does composer do?
A
Composer is a dependency management tool for PHP similar to npm for nodejs and bundle for ruby
Q
How do I install dependencies defined in composer.json file?
A
run as the command below "# cd /var/www/html/wiki && composer install –no-dev".
Q
How do we decide to take on works by a new composer?
A
In establishing a relationship with a new composer, we will consider the publication of a small number of commercially viable ‘representative’ works. These will most likely be smaller-scale c