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.

 

Why Use Composer?

  • 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.

 

Steps to Install Composer

Step 1: Log in via SSH

  • Access your hosting account using SSH.

  • Navigate to your home directory:

    Bash
    
    cd ~
    

Step 2: Create a Bin Directory

  • Create a directory for Composer:

    Bash
    
    mkdir -p ~/bin
    

     

Step 3: Download the Installer

  • Run the following command to download Composer’s installer:

    Bash
    
    wget https://getcomposer.org/installer -O composer-setup.php
    

     

Step 4: Install Composer

  • Execute the installer:

    Bash
    
    php ~/composer-setup.php
    

     

  • Move the Composer binary to your bin directory:

    Bash
    
    php ~/composer-setup.php --install-dir=$HOME/bin --filename=composer.phar
    

     

Step 5: Create a Helper Script

  • Create a helper script to run Composer easily:

    Bash
    
    cat > ~/bin/composer << 'EOF'
    #!/bin/bash
    php $HOME/bin/composer.phar "$@"
    EOF
    

     

  • Make the script executable:

    Bash
    
    chmod +x ~/bin/composer
    

Step 6: Update Your PATH

  • Add the bin directory to your PATH:

    Bash
    
    echo 'export PATH=$HOME/bin:$PATH' >> ~/.bash_profile
    source ~/.bash_profile
    
 

Verifying Installation

  • Run the following command to confirm Composer is installed:

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

 

Updating Composer

  • To update Composer to the latest version:

    Bash
    
    composer self-update
    
 
Помог ли вам данный ответ? 0 Пользователи нашли это полезным (0 голосов)

Powered by WHMCompleteSolution