Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Toc no bullet

Warning
titleWarning:

cPanel support does not provide assistance with the instructions in this document.

Overview

Composer is a dependency and package manager for PHP. For more information about Composer, read the Composer documentation. You can search for packages to download at the packagist.org website. 

Note
titleNotes:
  • Your cPanel account must have SSH access to the server to use Composer.
  • We added Composer in cPanel & WHM version 58.

How to set up Composer

In order to use Composer, you must install several PHP modules and verify that that you properly configured your server's php.ini file to allow Composer to run.

Required PHP modules

Note
titleNote:

You must perform these steps as the root user.

To use Composer, you must enable several PHP modules in EasyApache. For more information about EasyApache, read our EasyApache documentation. 

PHP ModuleDescription
Phar

Provides a way to store entire PHP applications into a single "phar" file (PHP Archive) for easy distribution and installation.

Note titled

Iconv

Provides a Character Set Conversion

Note
titleNote:

If you install this module, the MBstring module is not required.

Mbstring

Provides enhanced Chinese, Japanese, and other language support.

Note
titleNote:

If you install this module, the Iconv module is not required.

Required PHP directives

You must update the following PHP directives in the php.ini file:

Note
titleNote:

For more information about how to edit your php.ini file, read our How to Edit Your php.ini File documentation.

DirectiveRequired value
allow_url_fopenOn

detect_unicode

Off

Servers that use Suhosin

If you use Suhosin, you must add the Phar PHP module to the Suhosin whitelist in the server's php.ini file. Add the following line to you server's php.ini file:

Code Block
suhosin.executor.include.whitelist=phar
Note
titleNote:

For more information about how to edit your php.ini file, read our How to Edit Your php.ini File documentation.

What if I cannot edit the php.ini file?

If you cannot make changes to the php.ini file, you must manually run the following command each time you run Composer:

  • With Suhosin:

    Code Block
    languagebash
    php -d allow_url_fopen=1 -d detect_unicode=0 -d suhosin.executor.include.whitelist=phar $(which composer)
  • Without Suhosin:

    Code Block
    languagebash
    php -d allow_url_fopen=1 -d detect_unicode=0 $ {which composer}

If you use Composer often, you can create a Bash alias to perform this step for you. If you add an alias, you can run the composer command without any additional flags or options. Add the following line to your .bashrc file to create this alias each time that you log in to the server:

  • With Suhosin:

    Code Block
    languagebash
    alias composer="php -d allow_url_fopen=1 -d detect_unicode=0 -d suhosin.executor.include.whitelist=phar $(which composer)"
  • Without Suhosin:

    Code Block
    languagebash
    alias composer="php -d allow_url_fopen=1 -d detect_unicode=0 $(which composer)"

Troubleshoot Composer

Command not found

If you receive the command not found error message, you may need to add the proper path to your account's .bash_profile file. Add the following lines to your account's .bash_profile file:

Code Block
languagebash
source /etc/profile.d/cpanel-php-composer.sh

If you experience problems with the source option, add the PATH option to the .bash_profile file instead:

Code Block
languagebash
PATH=$PATH:/opt/cpanel/composer/bin
Note
titleNote:

You must log into the server again for any changes to the .bash_profile file to take effect.

The Composer self-diagnostic tool

Composer contains a self-diagnostic tool to ensure that you have properly configured PHP. You can run the diagnostic tool with the following command:

Code Block
languagebash
composer diagnose

The Checking platform setting section provides feedback about your server's PHP configuration and will inform you of any PHP configuration failures, as in the following example:

Code Block
languagebash
linenumberstrue
 $ composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: Warning: Accessing packagist.org over http which is an insecure protocol.
OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: FAIL
You are not running the latest stable version, run `composer self-update` to update (1.1.1 => 1.1.2)

Alternative diagnostic tools

If you require an alternate diagnostic tool, you can use the diagnostic tool from Composer's Github account. Run the following command:

Code Block
languagebash
curl https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer | php -- --check

This utility only checks the server's PHP configuration, is in the following example:

Code Block
languagebash
linenumberstrue
# curl https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer | php -- --check
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  286k  100  286k    0     0   466k      0 --:--:-- --:--:-- --:--:-- 1002k
All settings correct for using Composer
#  

Additional documentation

Localtab Group
Localtab
activetrue
titleSuggested documentation

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","thirdpartysoftware") and label = "whm" and space = currentSpace()

Localtab
titleFor cPanel users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","thirdpartysoftware") and label = "cpanel" and space = "ALD"

Localtab
titleFor WHM users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","thirdpartysoftware") and label = "whm" and space in (currentSpace(),"ALD")

Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("php","thirdpartysoftware") and space = "SDK"