# Installing Composer

> Install Composer in your hosting account over SSH so you can manage PHP libraries and frameworks such as Laravel.

Source: https://helpcenter.ruachost.com/developers/php/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.

## 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
  ```
