How to run Composer with Plesk PHP

Follow

Comments

15 comments

  • Avatar
    Robert Perrett

    Plesk latest ver as of Mar 30th.  Composer will not run under php7.2, but runs fine under 7.1 and 7.0

    -bash-4.2$ /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar update

    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

    0
    Comment actions Permalink
  • Avatar
    Konstantin Annikov

    @Robert Perrett
    Am I right that you are running Plesk Onyx 17.0/17.5 on CloudLinux environment?
    If so, we have an article regarding that:

    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

    Where it is mentioned, that such bug is fixed in Plesk Onyx 17.8 release.

    0
    Comment actions Permalink
  • Avatar
    Robert Perrett

    No, I am running the latest. Plesk Onyx Version 17.8.11 Update #47

    0
    Comment actions Permalink
  • Avatar
    Konstantin Annikov

    @Robert

    Thank you for the update.
    Can you also send me your OS version? I checked this command on CentOS 7 and all is working fine.

    You can check OS version using "#plesk version" command

    0
    Comment actions Permalink
  • Avatar
    Robert Perrett

    Product version: Plesk Onyx 17.8.11

         Build date: 2019/03/21 17:00

         OS version: CentOS 7.6.1810

           Revision: c3fb546fb867ac424d65da14d8b023f11ec0d150

       Architecture: 64-bit

    Wrapper version: 1.2

    0
    Comment actions Permalink
  • Avatar
    Robert Perrett

    I also have litespeed installed which changes the php being used

    0
    Comment actions Permalink
  • Avatar
    Konstantin Annikov (Edited )

    @Robert Perrett

    I have installed lighspeed and executed this command: 

    # /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar update

    with the following composer.json file: 

    CONFIG_TEXT: {
    "require": {
    "monolog/monolog": "1.0.*"
    }
    }

    And the package has been installed as usual:

    CONFIG_TEXT: Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 1 install, 0 updates, 0 removals
    \- Installing monolog/monolog (1.0.2): Downloading (100%)
    Writing lock file
    Generating autoload files

    So, I could not reproduce the issue. That is why I recommend you to contact Plesk technical support. Seems that your environment should be checked.

    0
    Comment actions Permalink
  • Avatar
    Robert (Edited )

    I also just installed centos 7 with plesk last version.

    As composer is pre-installed, I need to change the used composer path to point to a plesk higher php7.2 version

    For installation of drush 9 I get this

    composer require drush/drush:dev-master

    [InvalidArgumentException]
    Package drush/drush at version 9 has a PHP requirement incompatible with your PHP version (5.4.45)

    This would currently really help to use it with drupal 8  website.

    0
    Comment actions Permalink
  • Avatar
    Dinara Aspembitova (Edited )

    Hello @Robert,
    According to the documentation https://docs.drush.org/en/master/install/ you are running the command below:
    -----
    composer require drush/drush
    -----

    Looks like you run the command under system PHP
    ----------
    # php -v
    PHP 5.4.45 (cli) (built: Aug 23 2016 14:31:52)
    ----------

    In case if it is required to run the composer command under PHP 7.2, try the command below:
    --------------
    /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar require drush/drush
    --------------

    0
    Comment actions Permalink
  • Avatar
    Robert (Edited )

    OK so perhaps u should also tell people that we can use aliases so we again use only composer XXX

    Like 

    echo "alias composer='/opt/plesk/php/7.3/bin/php /usr/lib/plesk-9.0/composer.phar'" >> ~/.bashrc


    source ~/.bashrc

    0
    Comment actions Permalink
  • Avatar
    Nikita Nikushkin

    Hello @Robert,

    Thank you for the feedback!

    The information in the article is the general one

    Agree, an alias can be added, however, this customization is optional and calling the composer for the specific Plesk PHP version, e.g. as below:

    /opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar require drush/drush

    works fine

    0
    Comment actions Permalink
  • Avatar
    kenny nguyen (Edited )

    it's very easy by this way:

    ln -s /opt/plesk/php/{php_version_you_want_to_use}/bin/php /usr/local/bin/php

    Then you can use:

    composer install or composer update .... 

    0
    Comment actions Permalink
  • Avatar
    Ivan Postnikov

    Hello @kenny,

    Thank you for the comment.

    Indeed, this may be an alternative.

    0
    Comment actions Permalink
  • Avatar
    Robert

    I just install a fresh machine so again my drush that was installed via composer is not working for domain users.

    Composer & Drupal console work fine for domain users 

    Also the .promt looks different (color promt + ll not working) as under root.

    Where can I apply the same .bashrc settings from root user to domain user?

    0
    Comment actions Permalink
  • Avatar
    Taras Ermoshin

    Hello @Robert!

    You can copy root's .bashrc (and other similar files) to domain users' home directories. For example, the following command executed as root can be used (replace "user" with the domain's user username):

    cp ~/.bashrc $(cat /etc/passwd | grep user | awk -F : '{ printf $6 }')

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request