• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

Setup Composer For PHP Dependencies On CentOS 6

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
37
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Prerequisites
  3. Step 1: Install dependencies for the Composer program
  4. Step 2: Install the Composer program
    1. To install locally
    2. To install globally
  5. Step 3: Use Composer to install dependencies
  6. Optional: XDebug warning
  7. Want to contribute?


Introduction

Composer is a popular dependency manager for PHP which can simplify the installation and update of libraries necessary for your project. Nowadays, it’s becoming the de-facto standard in this area because of its unparalleled convenience and ease of use.

Unlike Yum or Apt, Composer never installs or updates any code or packages at the system level. Instead, code packages and libraries are managed within the project’s own directory on a per-project basis.

In this tutorial, I will show you how to install and use Composer to manage the dependencies of a PHP project. These steps were written for a CentOS 6 based Vultr LEMP server.

Prerequisites

  • Deploy a CentOS 6 server instance with PHP (no lower than 5.3.2, 5.3.4 or higher would be better) installed.
  • Log in as a common user with sudo permissions. You can find how to create such a user in this article.

Step 1: Install dependencies for the Composer program

sudo yum update
sudo yum install curl git php55u-cli.x86_64

Step 2: Install the Composer program

Composer can be installed either locally or globally. Local installation can bring you more flexibility for each single project and avoid permission issues while global installation is more convenient with a system-wide executable.

To install locally

To install Composer locally in your project directory ~/myproject:

cd ~
mkdir myproject
cd myproject
curl -sS https://getcomposer.org/installer | php

The Composer program, a PHP archive file called composer.phar, will be downloaded into your project directory.

You can test the installation with the command php composer.phar.

To install globally

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Once installed, you can use the command composer anywhere instead of using php composer.phar in a specific project directory. As a matter of convenience, I will use the global command composer in the following sections.

Step 3: Use Composer to install dependencies

To install dependencies with Composer, first, you need to create a file called composer.json within your project directory. This file defines all of the required dependencies. For example, the content of a composer.json file requiring the “psr/log” library could be like:

{
    "require": {
        "psr/log": "1.0.0"
    }
}

Here, “psr/log” represents “vendor/package”, “1.0.0” represents “version number”. Both of the two items can be found on Composer’s default repository site packagist.org.

If you need other libraries, just add a comma and a new line for each of them:

{
    "require": {
        "psr/log": "1.0.0",
        "phpunit/php-timer": "1.0.7",
        "symfony/event-dispatcher": "3.0.0"
    }
}

Then run the following command to install the libraries you have specified. Any libraries that your picks depend on will also be installed automatically.

composer install

All of the installed libraries will be saved in the ./vendor directory.

Anytime you modify the content of composer.json, or when you want to check if there are new versions, you should run the update command:

composer update

Also, some of the libraries provide autoload information. You can autoload them by simply adding the following sentence into your project code:

require __DIR__ . '/vendor/autoload.php';

That’s it. You are now ready to manage your project’s dependencies with Composer. For more details, visit the Composer official website.

Enjoy!

Optional: XDebug warning

You may see the warning “You are running composer with xdebug enabled…” when using Composer. If so, you can resolve the warning by following these steps.

Modify the configuration of PHP in the file /etc/php.d/15-xdebug.ini:

sudo vi /etc/php.d/15-xdebug.ini

Comment the line zend_extension=xdebug.so with a ;:

;zend_extension=xdebug.so

Save and quit:

:wq

Then reboot the system:

sudo reboot

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How To Install PowerDNS on CentOS

Next Post

How to Install Python 2.7 or Python 3.6 and Setup Virtual Environment on CentOS 6

Next Post

How to Install Python 2.7 or Python 3.6 and Setup Virtual Environment on CentOS 6

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet