03-Apr-2023
.
Admin
Hi Dev,
This simple article demonstrates of how to install and use php composer on centos 8. if you want to see example of install php composer on centos 8 then you are a right place. let’s discuss about download php composer on centos 8 latest. This article will give you simple example of installation php composer on centos 8. you will do the following things for configure and install a php composer on centos 8.
Install and use PHP composer on centOS 8; Through this tutorial, we will learn how to install and use PHP composer on CentOS 8.
Step 1: Install the PHP CLI
Open the command line or terminal and execute the following command into it to install PHP CLI on centOS 8:
sudo dnf install php-cli php-json php-zip curl unzip
Step 2: Download Composer with curl
Once the PHP CLI installation is completed, then execute the following command on the command line or terminal to download composer with curl:
curl -sS https://getcomposer.org/installer |php
Step 3: Move Composer file
Then move the composer file using the following command on centOS 8:
sudo mv composer.phar /usr/local/bin/composer
Step 4: Getting Started with Composer
We have successfully installed Composer on CentOS system. And now, we will learn how to use Composer in a PHP project.
Execute the following command on the command line or terminal to create PHP project using the composer command:
mkdir ~/my-first-composer-project
cd ~/my-first-composer-project
Once the PHP project creation is done, then execute the following command to initialize a new Composer project and install the carbon package:
composer require nesbot/carbon
Then create a file named testing.php and add the following code:
<?php
require __DIR__ . '/vendor/autoload.php';
use Carbon\Carbon;
printf("Now: %s", Carbon::now());
Execute the following command n command line or terminal to test above created PHP project with the help of PHP composer:
php testing.php
Output should look something like this:
Now: 2022-12-19 15:10:26
I hope it could help you...
#PHP