PHP Composer is a package management system for PHP which prevents users from having to “reinvent the wheel” when it comes to commonly-used website components like user authentication or database management. Composer is modeled on other popular package management systems like Ruby’s Bundler.
Note: For any 1&1 Cloud Server with Plesk, applications like PHP Composer should always be installed and managed through the Plesk interface.
PEAR was the first substantial package management system for PHP. However, PEAR has fallen out of favor with developers in recent years.
Due to the difficult process of getting packages approved for inclusion with PEAR, many of the packages available through PEAR are out of date. PEAR also requires users to install packages system-wide, whereas Composer allows you to install packages either system-wide or on a per-project basis.
Composer also tends to be better at handling dependencies, has a wider and more up-to-date codebase, and is more actively maintained.
Use the command php -v to check your PHP version:
1 2 3 4 5 |
user@localhost:~# php -v PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies |
In this example, the server is running PHP version 7.0.13.
Update your packages:
1 |
sudo apt-get update |
Install the curl utility:
1 |
sudo apt-get install curl |
Download the installer:
1 |
sudo curl -s https://getcomposer.org/installer | php |
Move the composer.phar file:
1 |
sudo mv composer.phar /usr/local/bin/composer |
Use the composer command to test the installation. If Composer is installed correctly, the server will respond with a long list of help information and commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
user@localhost:~# composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.3.2 2017-01-27 18:23:41 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message |