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?
Section titled “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
Section titled “Steps to Install Composer”Step 1: Log in via SSH
Section titled “Step 1: Log in via SSH”-
Access your hosting account using SSH.
-
Navigate to your home directory:
Terminal window cd ~
Step 2: Create a Bin Directory
Section titled “Step 2: Create a Bin Directory”-
Create a directory for Composer:
Terminal window mkdir -p ~/bin
Step 3: Download the Installer
Section titled “Step 3: Download the Installer”-
Run the following command to download Composer’s installer:
Terminal window wget https://getcomposer.org/installer -O composer-setup.php
Step 4: Install Composer
Section titled “Step 4: Install Composer”-
Execute the installer:
Terminal window php ~/composer-setup.php -
Move the Composer binary to your
bindirectory:Terminal window php ~/composer-setup.php --install-dir=$HOME/bin --filename=composer.phar
Step 5: Create a Helper Script
Section titled “Step 5: Create a Helper Script”-
Create a helper script to run Composer easily:
cat > ~/bin/composer << 'EOF'#!/bin/bashphp $HOME/bin/composer.phar "$@"EOF -
Make the script executable:
Terminal window chmod +x ~/bin/composer
Step 6: Update Your PATH
Section titled “Step 6: Update Your PATH”-
Add the bin directory to your PATH:
Terminal window echo 'export PATH=$HOME/bin:$PATH' >> ~/.bash_profilesource ~/.bash_profile
Verifying Installation
Section titled “Verifying Installation”-
Run the following command to confirm Composer is installed:
Terminal window composer -V -
You should see the Composer version number displayed.
Updating Composer
Section titled “Updating Composer”-
To update Composer to the latest version:
Terminal window composer self-update