Skip to content

Installing composer

Composer is a dependency manager for PHP that allows you to install and manage libraries and frameworks easily. On ruachost.com, Composer can be installed and configured directly from the command line.

  • Manage project dependencies automatically.
  • Keep libraries up to date with a single command.
  • Ensure consistent environments across development and production.
  • Required by popular frameworks such as Laravel, Symfony, and CodeIgniter.
  • Access your hosting account using SSH.

  • Navigate to your home directory:

    Terminal window
    cd ~
  • Create a directory for Composer:

    Terminal window
    mkdir -p ~/bin
  • Run the following command to download Composer’s installer:

    Terminal window
    wget https://getcomposer.org/installer -O composer-setup.php
  • Execute the installer:

    Terminal window
    php ~/composer-setup.php
  • Move the Composer binary to your bin directory:

    Terminal window
    php ~/composer-setup.php --install-dir=$HOME/bin --filename=composer.phar
  • Create a helper script to run Composer easily:

    cat > ~/bin/composer << 'EOF'
    #!/bin/bash
    php $HOME/bin/composer.phar "$@"
    EOF
  • Make the script executable:

    Terminal window
    chmod +x ~/bin/composer
  • Add the bin directory to your PATH:

    Terminal window
    echo 'export PATH=$HOME/bin:$PATH' >> ~/.bash_profile
    source ~/.bash_profile
  • Run the following command to confirm Composer is installed:

    Terminal window
    composer -V
  • You should see the Composer version number displayed.

  • To update Composer to the latest version:

    Terminal window
    composer self-update