How VPS - How to use/setup VPS
  • 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
34
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
How VPS

How VPS

Related Posts

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

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

February 25, 2022
How to Install BoltWire CMS on CentOS 7
CentOS

How to Install BoltWire CMS on CentOS 7

February 14, 2020
Showterm.io – A Terminal/Shell Recording, Upload and Share Tool for Linux
CentOS

Setup HTTP Authentication With Nginx on CentOS 7

February 14, 2020
Next Post

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

Install Polr on CentOS 8

How to Install Apache, MySQL, and PHP on CentOS 6

Leave a Reply Cancel reply

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

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Delete User Accounts with Home Directory in Linux

How to Enable TLS 1.3 in Apache on Fedora 30

3 years ago
How to Prepare/Configure OpenLiteSpeed for CMS or Application Installation

How to Prepare/Configure OpenLiteSpeed for CMS or Application Installation

4 years ago

How to Install Roadiz CMS on Debian 9

3 years ago

How to Find Files With SUID and SGID Permissions in Linux

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • 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

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

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

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

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
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • 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”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • 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

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

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