$ sudo apt install unzip curl<\/code><\/pre>\n\n\n\nOnce the above commands have run, verify the active PHP command-line version by executing:<\/p>\n\n\n\n
$ php -v<\/code><\/pre>\n\n\n\nYou should get similar output to this:<\/p>\n\n\n\n
Output\nPHP 7.4.13 (cli) (built: Nov 28 2020 06:24:43) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies<\/code><\/pre>\n\n\n\nStep 2: Install PHP Composer<\/h2>\n\n\n\n Download the composer executable file on your system using the following command.<\/p>\n\n\n\n
$ curl -sS https:\/\/getcomposer.org\/installer | php<\/code><\/pre>\n\n\n\nUse the following commands to make composer available globally for all users in your system. That way it can be used for all PHP applications on that system.<\/p>\n\n\n\n
$ sudo mv composer.phar \/usr\/local\/bin\/composer\n$ chmod +x \/usr\/local\/bin\/composer<\/code><\/pre>\n\n\n\nAfter installation is complete, you can run the following command to verify the composer version details along with options available with the Composer command.<\/p>\n\n\n\n
$ composer -v<\/code><\/pre>\n\n\n\nYou should get output that looks something like this:<\/p>\n\n\n\n
Output\n ______\n \/ ____\/___ ____ ___ ____ ____ ________ _____\n \/ \/ \/ __ \\\/ __ `__ \\\/ __ \\\/ __ \\\/ ___\/ _ \\\/ ___\/\n\/ \/___\/ \/_\/ \/ \/ \/ \/ \/ \/ \/_\/ \/ \/_\/ (__ ) __\/ \/\n\\____\/\\____\/_\/ \/_\/ \/_\/ .___\/\\____\/____\/\\___\/_\/\n \/_\/\nComposer version 1.6.4 2018-04-13 12:04:24\n\nUsage:\n command [options] [arguments]\n\nOptions:\n -h, --help Display this help message\n -q, --quiet Do not output any message\n -V, --version Display this application version\n --ansi Force ANSI output\n --no-ansi Disable ANSI output\n -n, --no-interaction Do not ask any interactive question\n --profile Display timing and memory usage information\n --no-plugins Whether to disable plugins.\n -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.\n -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n\nAvailable commands:\n about Shows the short information about Composer.\n archive Creates an archive of this composer package.\n browse Opens the package's repository URL or homepage in your browser.\n check-platform-reqs Check that platform requirements are satisfied.\n clear-cache Clears composer's internal package cache.\n clearcache Clears composer's internal package cache.\n config Sets config options.\n create-project Creates new project from a package into given directory.\n depends Shows which packages cause the given package to be installed.\n diagnose Diagnoses the system to identify common errors.\n dump-autoload Dumps the autoloader.\n dumpautoload Dumps the autoloader.\n exec Executes a vendored binary\/script.\n global Allows running commands in the global composer dir ($COMPOSER_HOME).\n help Displays help for a command\n home Opens the package's repository URL or homepage in your browser.\n info Shows information about packages.\n init Creates a basic composer.json file in current directory.\n install Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.\n licenses Shows information about licenses of dependencies.\n list Lists commands\n outdated Shows a list of installed packages that have updates available, including their latest version.\n prohibits Shows which packages prevent the given package from being installed.\n remove Removes a package from the require or require-dev.\n require Adds required packages to your composer.json and installs them.\n run-script Runs the scripts defined in composer.json.\n search Searches for packages.\n self-update Updates composer.phar to the latest version.\n selfupdate Updates composer.phar to the latest version.\n show Shows information about packages.\n status Shows a list of locally modified packages, for packages installed from source.\n suggests Shows package suggestions.\n update Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.\n upgrade Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.\n validate Validates a composer.json and composer.lock.\n why Shows which packages cause the given package to be installed.\n why-not Shows which packages prevent the given package from being installed.<\/code><\/pre>\n\n\n\nStep 3: How to use Composer<\/h2>\n\n\n\n For Existing Project<\/strong>: Switch to the application root directory and run the below command. It will read composer.json<\/strong><\/em> file and install dependencies for the application.<\/p>\n\n\n\n$ composer install<\/code><\/pre>\n\n\n\nFor New Projects:<\/strong> To create a new project, switch to the project directory, and install required modules as below command.<\/p>\n\n\n\n$ mkdir mynewproject && cd mynewproject\n$ composer require psr\/log<\/code><\/pre>\n\n\n\nThe above command will install psr\/log<\/strong> module under the vendor directory. It also creates an entry in composer.json<\/em><\/strong> and updates composer.lock<\/strong><\/em> as well.<\/p>\n\n\n\nBonus Step: Upgrading Composer<\/h2>\n\n\n\n Composer is capable of upgrading itself by running the self-update command to upgrade Composer to the latest version. You can also download the latest version of the composer by executing the same commands above used for installation and it will upgrade Composer.<\/p>\n\n\n\n
$ sudo composer self-update<\/code><\/pre>\n\n\n\nConclusion<\/h2>\n\n\n\n This guide has shown you how to install PHP Composer. It goes further to show you how to use it as well as upgrade it using the command-line interface.<\/p>\n","protected":false},"excerpt":{"rendered":"
This quick guide will show you how you can install PHP Composer on Ubuntu 20.04 | 18.04 and Debian based Linux systems. The PHP Composer is an application-level dependency management…<\/p>\n","protected":false},"author":1,"featured_media":9450,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,16,18],"tags":[183,350,354,424,433,449,452,591,598],"yoast_head":"\n
How to Install PHP Composer on Ubuntu 20.04 | 18.04<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n