BuycPanel Blog

BuycPanel Blog

Latest news and updates

Setting up a PHP Composer for your cPanel

Posted by Allison on 11 01 2017.

A PHP package and dependency manager, Composer can help you with manage and configure your cPanel account even better. For instance, with this manager, you can easily look for downloadable packages found at the website packagist.org.

In order to set up a composer on your cPanel account though, you should first have server SSH access. In addition you should have the version 58 of the cPanel & WHM.

Setting Up a Composer

For you to use this program, there are several things you need to do first. One of these is the installation of a number of PHP modules. You should also make sure that you have correctly configured the php.ini file of your server so that you will not have problems running Composer.

PHP Modules Required to Use Composer

In order to install the required PHP modules, you should log in as a root user. From there, you would have to enable the correct…

A PHP package and dependency manager, Composer can help you with manage and configure your cPanel account even better. For instance, with this manager, you can easily look for downloadable packages found at the website packagist.org.

In order to set up a composer on your cPanel account though, you should first have server SSH access. In addition you should have the version 58 of the cPanel & WHM.

Setting Up a Composer

For you to use this program, there are several things you need to do first. One of these is the installation of a number of PHP modules. You should also make sure that you have correctly configured the php.ini file of your server so that you will not have problems running Composer.

PHP Modules Required to Use Composer

In order to install the required PHP modules, you should log in as a root user. From there, you would have to enable the correct EasyApache PHP modules.

Here are the PHP modules you need to have the ability to use Composer.

  1. Phar. This module allows you to store complete PHP applications in just one “phar” file (PHP Archive). This then makes it easy for you to install and distribute. By default, EasyApache4 has this module already installed.
  2. Iconv. With this module, you can use a Character Set Conversion. Installing this module will no longer require you to have the MBstring module installed.
  3. This one allows you to use advanced support for a variety of languages such as Japanese and Chinese. When you opt for this module, you no longer have to install the Iconv one.

PHP Directives Needed for Using Composer

There are also several PHP directives you have to update found in your account’s php.ini file. These include the following:

  • Turning on the “allow_url_fopen”
  • Turning off the “detect_unicode”

For Suhosin-Using Servers

For those who use servers with Suhosin, they have to add another module to their whitelist found in the php.ini.file of their server. This is the Phar PHP module.

Add the line “suhosin.executor.include.whitelist=phar” (without the quotation marks) to the php.ini file of your server.

Troubleshooting for Problems with Editing the php.ini File

Just in case you have trouble making changes to your server’s php.ini file, your last resort is to manually execute these commands when you need to use Composer.

  • For Suhosin Users: php -d allow_url_fopen=1 -d detect_unicode=0 -d suhosin.executor.include.whitelist=phar $(which composer)
  • For Non-Suhosin Users: php -d allow_url_fopen=1 -d detect_unicode=0 $ {which composer}

When you always run Composer, you may want to create a Bash alias. Doing so will allow you execute the composer command without having to add any options or flags.

Adding any of the appropriate lines to the .bashrc file will allow you to generate the alias every time you log in to your server:

  • For Suhosin Users: alias composer=”php -d allow_url_fopen=1 -d detect_unicode=0 -d suhosin.executor.include.
  • For Non-Suhosin Users: alias composer=”php -d allow_url_fopen=1 -d detect_unicode=0 $(which composer)”

There are many other things you should know about Composer, but make sure you master the ones discussed above first.