Installing PHP Composer on CentOS 7
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Composer is not a package manager in the same sense as Yum or Apt is. Although it deals with "packages" or libraries, it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default, it does not install anything globally. Thus, it is a dependency manager.
In this guide, we will install PHP Composer on CentOS 7.
Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.
Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.
Updating System Packages
It is recommended that you update the system to the latest packages before beginning any significant installations. Issue the command below:
It is recommended that you update the system to the latest packages before beginning any significant installations. Issue the command below:
sudo yum update -y
Install PHP 7: You can read this guide on installing PHP 7 on your CentOS7 server if you don't have PHP 7 installed.
Next, install the PHP Command Line Interface package and other dependencies by issuing the command below:
sudo yum install php-cli php-zip wget unzip
After installing the PHP CLI package, proceed to download the Composer installer script by issuing the command below:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
We can verify the data integrity of the downloaded script by comparing the script SHA-384 hash with the latest installer hash found on the Composer Public Keys/Signatures page.
Issue the command below:
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
Next, issue the command below to verify that the installation script is not corrupted run the following command:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Lastly, we can now issue the following command to install Composer in the
/usr/local/bin
directory:sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
You can also issue the command
"composer"
to print Composer’s version, commands, and arguments as shown below:
You can read the official Composer documentation for more information on Composer.
Tidak ada komentar:
Posting Komentar