PHP Composer is a package dependancy management tool for PHP used by developers to manage their PHP based projects / applications…. You probably have seen some PHP applications requiring that you have composer installed on the system in order to get the package installed and working…
PHP composer is frequently used to factlitate the installation and update of dynamic PHP applications that needs easier management… using composer dependancies tool, these packages can easily be installed and managed… It maintains a list of required packages in a JSON file called composer.json.
This brief tutorial is going to show students how to quickly install PHP Composer on Ubuntu 16.04 / 17.10 and 18.04
One requirement for install Composer is to have PHP installed… so when you’re ready, follow the steps below to get Compser installed.
Step 1: Install PHP
Composer requires PHP 5.3 or higher… to install PHP on Ubuntu, run the commands below
sudo apt install php
If you need to install other versions of PHP that’s not available in Ubuntu default repositories for your system, run the commands below to install a third-party repository which contains PHP 7.0, 7.1, 7.2 and up…
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Now simple run the commands below to install PHP 7.2… change the number value to install 7.1, 7.3 and so forth..
sudo apt install php7.2
Step 2: Install Compser
Now that PHP is installed… you can now run the commands below to install Composer
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
The commands above will download Composer from its maintainer page and install it into the /usr/local/bin directory… this is a local global directory for application executables…
All settings correct for using Composer
Composer (version 1.6.4) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
Now simply run the commands below to test whether Composer is installed.
The output should look like something below
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
Composer version 1.6.4 2018-04-13 12:04:24
command [options] [arguments]
-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 3 for debug
Now when you want to install a PHP based application that requires Composer, simple reference this page to learn how to install Compser… after that, continue with getting your PHP application on Ubuntu.
Composer can also be upgraded by running the commands below… this will upgrade all packages associated with Composer…
sudo composer self-update
You may also like the post below:
How to Install Typesetter CMS on Ubuntu 16.04 / 17.10 / 18.04 with Apache2, PHP 7.2 with Let’s Encrypt SSL/TLS Certificates