Unable to install PHP dependencies via Composer when PHP by CloudLinux is used: Class 'Phar' not found in /usr/lib64/plesk-9.0/composer.phar

Created:

2017-07-11 08:42:07 UTC

Modified:

2017-08-16 17:08:12 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Unable to install PHP dependencies via Composer when PHP by CloudLinux is used: Class 'Phar' not found in /usr/lib64/plesk-9.0/composer.phar

Applicable to:

  • Plesk Onyx 17.5 for Linux

Symptoms

Plesk is installed on CloudLinux 7.

PHP shipped by CloudLinux is selected using PHP Selector.

When trying to install PHP dependencies at Domains > example.com > Applications > path_to_composer.json > Install Dependencies , the task is failed with the following error:

PLESK_INFO: PHP Fatal error: Uncaught Error: Class 'Phar' not found in /usr/lib64/plesk-9.0/composer.phar:23
Stack trace:
#0 {main}
thrown in /usr/lib64/plesk-9.0/composer.phar on line 23

Cause

It is a Plesk bug PPPM-6724 . The fix is planned to be included in one of the next Plesk next updates.

Resolution

Workaround I

Replace the /usr/local/psa/lib/modules/python/composermng/composermng.py file with the patched one:

1. Download the patched file and unpack it:

# wget https://plesk.zendesk.com/hc/article_attachments/115000970673/composermng.py.tar.gz

# tar -zxvf composermng.py.tar.gz

2. Backup the original file and replace it with the patched one:

# mv /usr/local/psa/lib/modules/python/composermng/composermng.py /usr/local/psa/lib/modules/python/composermng/composermng.py.bak

# mv composermng.py /usr/local/psa/lib/modules/python/composermng/composermng.py

Workaround II

Install a separate Composer into domain's folder along with PHP dependencies:

1. Allow access to the server via SSH for subscription's system user at Domains > example.com > Web Hosting Access > Access to the server over SSH , in the drop-down select /bin/bash and click OK .
2. In command-line interface, change current directory to domain's document root and switch to subscription's system user:

# cd /var/www/vhosts/example.com/httpdocs/
# su user

3. Download and install the Composer:

$ php -r "copy('https://getcomposer.org/installer ', 'composer-setup.php');"
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
$ php composer-setup.php
$ php -r "unlink('composer-setup.php');"

4. Install PHP dependencies using the newly installed Composer:

$ php composer.phar install

Attachments:

Have more questions? Submit a request
Please sign in to leave a comment.