skip to Main Content
  1. Clone fresh Magento 2 instance;
    2.Run composer:install

Fatal Error:
PHP Fatal error: Uncaught Error: Undefined class constant ‘PRE_COMMAND_RUN’

5

Answers


  1. This was an issue with Composer, By installing latest version of Composer solved it.
    The bug for the constant variable PRE_COMMAND_RUN is raised and closed.

    Login or Signup to reply.
  2. You need install latest version of composer, upgrade steps given below.

    — Remove existing composer

    Debian/Ubuntu

    sudo apt-get remove composer
    

    Centos/Redhat

    sudo yum remove composer
    

    Get the latest composer using wget.

    cd /tmp
    sudo curl -sS https://getcomposer.org/installer | php
    

    Move composer executable to PATH so it can be accessible globally.

    sudo mv composer.phar /usr/local/bin/composer
    

    To check the composer version

    composer -V
    
    Login or Signup to reply.
  3. You have to reinstall the Composer and use the latest composer version

    To do that you can follow the following steps:

    Step #1) Remove the current composer:

    sudo apt-get remove composer
    

    Step #2) install the composer , you can using following commands

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

    then to make sure you have the latest Composer , run the following command

    php composer.phar -V
    

    Now, your ready to install Magento,
    to install Magento via composer :

    composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition YourProjectName
    

    if the project folder name is exist , remove the folder and try again to install magento

    Login or Signup to reply.
  4. You probably have an outdated version that doesn’t even support self-update unfortunately.
    So here’s a oneliner to install the latest version in /usr/local/bin:

    curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
    

    Check:

    which -a composer
    /usr/local/bin/composer --version
    composer --version
    
    Login or Signup to reply.
  5. Composer self-update wasnt working with my composer version, I use ubuntu(LEMP).
    Latest version of composer was installed – 1.6.3 I think.

    We need this 1.10.17.

        sudo apt remove compsoer
        php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
        php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
        sudo php composer-setup.php --version=1.10.17 --install-dir=/usr/bin --filename=composer 
    

    Check version:

    composer --version
     
    output: 1.10.17
    

    To be sure remove all vendor and cache:

    rm -rf vendor/*
    composer clear-cache
    composer update
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search